Heres the code about threads.....I don't know the difference between those 2 new() statements.
Runnable r=new Runnable() {
public void run() {
System.out.print("Cat");
}
};
Thread t=new Thread(r) {
public void run() {
System.out.println("Dog");
}
};
t.start();
Output is Dog But why and how ?
Anonymous User
14-Oct-2013Because you override Thread#run(), so this method is eventually executed when you start the thread. The default Thread#run() delegates to the passed-in Runnable. Rule of thumb: Either provide a Runnable or override Thread#run(), but don't do both!