This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question on threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question on threads" Watch "Question on threads" New topic

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());;;
public void run()
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


I agree. Here's the link:
subject: Question on threads
It's not a secret anymore!