File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling Thread By Start() and Run()

 
RAGU KANNAN
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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");
b.start();
a.run();
}
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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. a.run() will not start a thread. The run method is mounted on main's call stack.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic