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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads" Watch "Threads" New topic


Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Dear friends,
Why does the program not produce any output on running?
public class Base extends Thread{
public static ThreadGroup group = new ThreadGroup("gprs");
public static void main( String []args){
Thread th1 = new Thread(group, "Thread1");
Thread th2 = new Thread(group, "Thread2");
public synchronized void run(){
System.out.println(" Threads ! Please Stop ");
catch(InterruptedException ie){}
lakshmi nair
Ranch Hand

Joined: Oct 11, 2000
Posts: 63
That is because you are not calling the run method which you overrided, but the run method in class Thread. You are creating two threads (Thread class objects)and calling start. Instead, try creating your class object and call start() which will execute the run and print " Threads ! Please Stop "
I agree. Here's the link:
subject: Threads
jQuery in Action, 3rd edition