File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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
I agree. Here's the link:
subject: Calling Thread By Start() and Run()
It's not a secret anymore!