This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Calling Thread By Start() and Run() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Calling Thread By Start() and Run()" Watch "Calling Thread By Start() and Run()" New topic

Calling Thread By Start() and Run()

Ranch Hand

Joined: Dec 16, 2005
Posts: 103

what is the differnet between calling a Thread by start() and run().

Thanks, Raghu.K

public static void main(String[] args) {
MyThread a = new MyThread("A");
MyThread b = new MyThread("B");
Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

The start method will create a seperate thread of execution. When you invoke the run method, its not a seperate thread. This program has two threads running. They are main and thread b. will not start a thread. The run method is mounted on main's call stack.

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Have you checked out Aspose?
subject: Calling Thread By Start() and Run()
It's not a secret anymore!