2
使用setThreadPool()我想看看如何使用setThreadPool()
功能。比方說,我的主類是以下幾點:如何在碼頭
import javax.servlet.SingleThreadModel;
import org.eclipse.jetty.server.Server;
public class FServer implements SingleThreadModel {
public static void main(String[] args) throws Exception {
Server server = new Server(x);
server.setHandler(new Handler());
server.start();
server.join();
}
}
當試圖添加setThreadPool()
,我總是要求執行抽象方法。
我的問題是,如何設置Jetty的ThreadPool長度而不必強制使用XML配置文件,即如server.setThreadPool(5)
其中5是同時線程的數量?
偉大的工作對我來說,從開始過多線程停止碼頭6。我發現這個設置在這裏解釋http://docs.codehaus.org/display/JETTY/Newbie+Guide+to+Jetty#NewbieGuidetoJetty-ThreadPooloptional。 ExecutorThreadPool [如下所述](http://stackoverflow.com/a/7454163/270662)似乎在Jetty 7+中可用 – mxro
Jetty 9不再具有server.setThreadPool()命令。我現在如何設置線程池? – Luke
現在它可以通過構造函數來設置:'Server(@Name(「threadpool」)ThreadPool pool)' –