This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 18116
    
  39

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
 
Similar Threads
Regarding Threads
Threads
Threads and run()
Thread problem.
Lock Mechanism Doubt