Found this on a mock exam.....
public class NiceThreads implements Runnable
{
public void run()
{
while(true)
{
}
}
public static void main(
String args[])
{
NiceThreads nt1 = new NiceThreads();
NiceThreads nt2 = new NiceThreads();
NiceThreads nt3 = new NiceThreads();
nt1.run();
nt2.run();
nt3.run();
}
}
1. The code does not compile - "nt2.run() is never reached"
2. The code compiles and runs 3 non ending non demon threads.
3. The code compiles but runs only 1 non ending, non demon
thread.
The answer given is 3 which I couldn't understand..... I thought it would be 2.....
Does a thread (which goes into an infinite loop prevent other threads from being created/run???
Any inputs are greatly appreciated.....
Thanks,
Shafeeq