@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String param = request.getParameter("param");//獲取發(fā)送的參數(shù)
String content = request.getParameter("content");//獲取發(fā)送的參數(shù)
ExecutorService threadPool = Executors.newFixedThreadPool(5);//定義長度為5的線程池
threadPool .execute(new Runnable(){
@Override
public void run() {
//在此處如何獲取request對象
//如何獲取param參數(shù)
//如何獲取content參數(shù)
//邏輯代碼,數(shù)據(jù)庫操作
}
});
}
1 回答

慕虎7371278
TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超4個(gè)贊
簡單封裝下即可,比例param參數(shù)
public class MyTask implements Runnable{
private String param;
public MyTask(String param){
this.param = param;
}
@Override
public void run() {
......
}
}
//在doGet()中
MyTask task = new MyTask(param);
threadPool .execute(task);
添加回答
舉報(bào)
0/150
提交
取消