aspose file tools
The moose likes Beginning Java and the fly likes Doubt regarding start() method of Thread class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Doubt regarding start() method of Thread class" Watch "Doubt regarding start() method of Thread class" New topic
Author

Doubt regarding start() method of Thread class

Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1142

Hi

I read that we need to call start() method on a Thread object to make it a thread of execution. How does start() method internally handle the call to run()? Why is the start() method there at all? I mean we could have directly started the thread by saying t.run(). Why a separate method to start() which then calls run()?


~ Mansukh
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1295

Well, the simple answer is:
If you call run method, you are just invoking a method on an object within the same thread. No new thread is created.

However, when you call start method, a new system level thread is created, proper context (a separate stack etc.) is set, and that thread is further executed concurrently (here, run method is invoked by thread manager).


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD)
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1142

Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt regarding start() method of Thread class
 
Similar Threads
Thread starting sequence
regarding thread run method
Thread start( ) method , can only be called once?
Thread Start() method
Why start() method