| Author |
Question on threads
|
Dinesh Tahiliani
Ranch Hand
Joined: Aug 06, 2007
Posts: 486
|
|
public class Threads4 implements Runnable { public static void main (String[] args) { Thread t = new Thread(new Threads4()); t.run(); t.run(); t.start(); } public void run() { System.out.println("running"); } } o/p is-- runningrunningrunning Why this is printing 3 times the running. Can anyone please expalin me this Source " My own code "
|
Thanks<br />Dinesh
|
 |
Rohit Garg
Ranch Hand
Joined: Feb 05, 2008
Posts: 30
|
|
Its because two times, you have called the run method yourself and once it will be called by the thread you have created Regards.
|
Regards,
Rohit.
|
 |
 |
|
|
subject: Question on threads
|
|
|