|
本帖最后由 superfang 于 2011-2-21 18:19 编辑
=========java代码=========================
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
public class TT {
public static void main(String[] args) {
// 线程池
ExecutorService exec = Executors.newCachedThreadPool();
// 只能5个线程同时访问
final Semaphore semp = new Semaphore(10);
// 模拟20个客户端访问
for (int index = 0; index < 20; index++) {
final int NO = index;
Runnable run = new Runnable() {
public void run() {
try {
// 获取许可
semp.acquire();
int c;
try {
URL url = new URL("http://localhost:7080/webjava/");
java.net.URLConnection uc = url.openConnection();
java.io.InputStream in = uc.getInputStream();
System.out.println("Accessing: " +NO +" "+ in.toString());
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println("Accessing: " + NO);
//Thread.sleep((long) (Math.random() * 10000));
// 访问完后,释放
semp.release();
} catch (InterruptedException e) {
}
}
};
exec.execute(run);
}
// 退出线程池
exec.shutdown();
}
}
===========loadrunner 代码============
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
// Tweb.main((String []) null);
TT.main((String []) null);
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
在Vuser中测试通过,但是在controller里面报如下的错误
错误1: Abnormal termination, caused by mdrv process termination.
错误2:
Error (-17998): Failed to get [param not passed in call] thread TLS entry.
不知道是不支持呢,还是别的原因....
如有遇到同样的问题,请赐教... |
|