java模拟并发操作进行压力测试计算机等级考试
文章作者 100test 发表时间 2010:01:24 16:53:50
来源 100Test.Com百考试题网
import java.io.BufferedReader.
import java.io.File.
import java.io.FileInputStream.
import java.io.InputStreamReader.
import java.io.PrintWriter.
import java.net.HttpURLConnection.
import java.net.URL.
import java.util.HashMap.
import java.util.Map.
import java.util.concurrent.ExecutorService.
import java.util.concurrent.Executors.
import java.util.concurrent.Semaphore.
public class ConcurrentTest {
private static int thread_num = 200.
private static int client_num = 460.
private static Map keywordMap = new HashMap().
static {
try {
InputStreamReader isr = new InputStreamReader(new FileInputStream(
new File("clicks.txt")), "GBK").
BufferedReader buffer = new BufferedReader(isr).
String line = "".
while ((line = buffer.readLine()) != null) {
keywordMap.put(line.substring(0, line.lastIndexOf(":")), "").
}
} catch (Exception e) {
e.printStackTrace().
}
}