Now if you invoke the run() method on the directly, it would still be very well executed but within the thread of the calling class.
Sunday, May 1, 2011
In Java what happens when you invoke the run() method directly on a Thread rather than initiating it via Thread.start()
This question can be used to judge the candidate's hands on experience with Java and Threads. Essentially whenever you create your own Thread (either via extending the Thread class or implementing the Runnable interface), you write the logic of the thread in public void run() method and initiate the thread via Thread.start() method which invokes the run method in a separate thread.
Labels:
Core Java,
Intermediate,
Java - Threads
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment