wood burning stoves*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 18546
    
  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)
 
Don't get me started about those stupid light bulbs.
 
subject: Threads
 
Similar Threads
Thread problem.
Lock Mechanism Doubt
Regarding Threads
Threads
Threads and run()