wood burning stoves 2.0*
The moose likes Java in General and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Threads" Watch "Threads" New topic
Author

Threads

Vihanga Rajalingam
Greenhorn

Joined: Aug 26, 2012
Posts: 3

class Demo{
public static void main(String args[]){
MyRunnable r=new MyRunnable();
//r.start();
Thread t1=new Thread(r);
t1.start();
for(int i=0;i<100;i++){
System.out.println("main thread "+i);
}
}
}

class MyRunnable implements Runnable{
public void run(){
for(int i=0;i<100;i++){
System.out.println("My thread "+i);
}
}
}


What is the explanation of this program?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18917
    
  40

Vihanga Rajalingam wrote:


What is the explanation of this program?



Looks like a pretty straightforward example. Can you tell us what do you think is going to happen? Have you run it? And what are you confused about?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads