import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore; public class ThreadTest {
private static int thread_num = 500;
private static int client_num = 5000; public static void main(String[] args,String no) {
ExecutorService exec = Executors.newCachedThreadPool(); final Semaphore semp = new Semaphore(thread_num); for (int index = 0; index < client_num; index++) { final int NO = index; Runnable run = new Runnable() {
public void run() {
try {
semp.acquire();
//HttpClientTest.postLogin();
System.out.println("Thread:" + NO);
semp.release();
} catch (Exception e) {
e.printStackTrace();
}
}
};
exec.execute(run);
}
exec.shutdown();
}
}