This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads" Watch "Threads" New topic


Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295


I am using the following code but it compiles fine but do not print "In Run" in console . Whats the reason behind this ?. Please help . Thanks in advance .

public class Tintin implements Runnable{
public static void main(String ...args) {
new Thread().start();

public Tintin() {

public void run() {
System.out.println("In Run");

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41129
new Thread().start()

You're not creating an instance of the Tintin class, but an instance of the Thread class.

Ping & DNS - my free Android networking tools app
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Thanks friend
Mo Jay
Ranch Hand

Joined: Feb 16, 2009
Posts: 83
You need to specify the object instance that you to run the thread on, do the following and it should work fine:

Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

Job that is done is the thread class's run() which has nothing and neither has been overriden. To make your run execute you need to tell the thread to use your run() by passing the job instance.

[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
I agree. Here's the link:
subject: Threads
Similar Threads
Thread doubt
run method overriding -threads
problem in threads(sun accesibility test)
Fav comic book character....
public void run ()