多线程单元测试

package com.qilu.test;

import org.junit.Test;

public class SimpleThread extends Thread {
private int countDown = 5;
private int threadNumber;
private static int threadCount = 0;

public SimpleThread() {
threadNumber = ++threadCount;
System.out.println("Making " + threadNumber);
}
@Test
public void run() {
while (true) {
System.out
.println("Thread " + threadNumber + "(" + countDown + ")");
if (--countDown == 0)
return;
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 0; i < 5; i++)
new SimpleThread().start();
System.out.println("All Threads Started");
}


}

代码编写时间:45%

      测试时间:55%

原文地址:https://www.cnblogs.com/glmmm/p/4789006.html