Thread: can anyone tell what happens internally when start() is called on thread object?

Forum : Threads and Synchronization   28-4-2015 12:00:00 AM
User Image
Rashmiranjan204

Newbie

Joined: Apr 20, 2017

Points: 100

Threads: 3

Posts: 1

can anyone tell what happens internally when start() is called on thread object?

| Quote Date : Apr 28, 2015    Views:2005    

can anyone tell what happens internally when start() is called on thread object?

tags: java

Comments

User Image
Santosh25

Newbie

Joined : Feb 21, 2018

Points : 100

Threads: 0

Posts: 1

Re: can anyone tell what happens internally when start() is called on thread object?

Reply Date : Apr 1, 2018

When we call start() on a particular class which is extending from java.lang.Thread
control passes to the Thread class Start().
 
 Basically It is three step process
 
 1.It will register Object on which you calling start() with Thread Scheduler and creates one thread for each Object based on default priority to execute run().
 2.performs some special mandatory activities as creating identity for thread, making thread in ready state.
 3.call run() method.
 
Thread scheduler is a part of JVM(Java Virtual Machine), here Thread scheduler is responsible for calling run(), assigning CPU to the thread and tracking the thread.

Hope you got an idea on this question !?

User Image
Amit1992

Newbie

Joined : Jun 25, 2017

Points : 100

Threads: 4

Posts: 6

Re: can anyone tell what happens internally when start() is called on thread object?

Reply Date : Mar 13, 2018

Thank you, men...

"When we call the start method It will create the new thread and register with thread scheduler, Then it will check the thread status, mean is thread already started or not by checking the status value (0 or 1) if thread status is 1 mean thread already running or started so it will immediately?  throw ThreadIllegalStartException() other wice i will start new thread and added it existing executing thread group."

Replied by Haribabu4578
User Image
javaMad

Newbie

Joined : Mar 12, 2018

Points : 100

Threads: 0

Posts: 13

Re: can anyone tell what happens internally when start() is called on thread object?

Reply Date : Mar 13, 2018

If we call start() then first inside the thread class the logic is there to create new Thread . Immediately that the execution is not started
it's depending on priority we it get executed .when it get a chance to execute it called run()? in stack(Thread).





User Image
radhareddy

Newbie

Joined : Jun 27, 2017

Points : 165

Threads: 59

Posts: 123

Re: can anyone tell what happens internally when start() is called on thread object?

Reply Date : Jul 17, 2017

Internally when start() is called on thread object a new thread of execution with a new call stack starts. The state of thread changes from new to runnable. When the thread gets chance to execute its target run() method starts to run.
?

Load More

No More Comments