kyoto dreams
Friday, January 06, 2006
  Three The following code compiles and runs, but only 1 thread is ever created. What is the problem and how would you fix it?



public class T extends Thread {
public static void main(String []args) {
for (int i = 0; i < 10; i++) {
T t = new T();
t.run();
}
}



public void run() {
while (true) {
System.out.println(System.currentTimeMillis());

try {
Thread.sleep(1000);
}
catch (InterruptedException e) {}
}
}
}


 
Comments: Post a Comment

<< Home

ARCHIVES
May 2005 / June 2005 / August 2005 / January 2006 / March 2006 /


Powered by Blogger