Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads: differnece between start() and run() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads: differnece between start() and run()" Watch "Threads: differnece between start() and run()" New topic

Threads: differnece between start() and run()

sameer inamdar
Ranch Hand

Joined: Jul 04, 2005
Posts: 40
Please share your understanding about the start and run method in a Thread
Thread t
Its basic that we can call direct run() method of the runnable interface
and call start method of the Thread class.
But I want to know wether there is specific rule for them or they are same.

Dream!!! Set Vision !! Transform Vision to Mission by Actions on Deadlines!.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
the start() method , creates a new call stack and put this thread in new state. But the run() methods has the job or the stuffs needs to be executed in a seperate thread. This method doesnt create a new thread. When a thread goes to running state then it executes the statements in the run method.

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Wensheng Li

Joined: Jul 08, 2005
Posts: 16
Yes, basically calling start() method will create a separate new thread in your program then this new thread will run the codes specified by run().

Calling run() will of course also causes the codes in run() to be run but in the current thread(for example, the main program). No new thread will be created.

SCWCD 1.4(In progress)<br />SCJP 5.0<br />IBM Certified Solutions Expert for Webshpere Studio, V3.5 (retired)
I agree. Here's the link:
subject: Threads: differnece between start() and run()
It's not a secret anymore!