Hi,
I am going to take scjp1.6 exam soon.I have some doubts in K&B book.Actaully I don't understand the output of the below code which is in K&B book. Will anyody explain me?
The question is:
public class Starter implements Runnable{
void go(long id){
System.out.println( id);
}
public static void main (
String [] args){
System.out.print(Thread.currentThread().getID() + " " );
// insert code here
}
public void ru(){
go(Thread.currentThread().getID());
}
The fragments are,
1. new Starter.run();
2. new Starter().start();
3. new
Thread(new Starter());
4. new Thread(new Starter()).run();
5. new Thread(new Starter()).start();
The answers are,
Only one might product the output 4 2
Exactly two might product the output 4 4
regards,
jaya