I'm trying to write a unit test that requires mulitple threads. However, it seems that the threads just stop part way through execution. Consider the following code:
public class Test {
@org.junit.Test
public void TestThreads() {
new Thread(new Runnable() {
public void run() {
for (int i = 1; i < 1000; i++) System.out.println(i);
}
}).start();
}
}
If I run this unit test, it will generally stop displaying output somewhere between 140-180. If I convert this code into a regular class and run it, it works fine. Does anybody have any idea what I'm missing here?
Thanks, - Andrew.