Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.junit.Test;
- public class NewThreadTest {
- public static void main(String[] args) {
- new Thread(new InfiniteRunnable()).start();
- //Thread will execute forever, but if we terminate the JVM with System.exit(0) - it will stop
- //System.exit(0);
- }
- //Test will pass and Junit runner will terminate the JVM with System.exit(0)
- @Test
- public void test() {
- new Thread(new InfiniteRunnable()).start();
- }
- private static class InfiniteRunnable implements Runnable {
- @Override
- public void run() {
- while (true) {
- Thread.yield();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment