本文整理匯總了Java中org.eclipse.jetty.util.thread.QueuedThreadPool.setMaxQueued方法的典型用法代碼示例。如果您正苦於以下問題:Java QueuedThreadPool.setMaxQueued方法的具體用法?Java QueuedThreadPool.setMaxQueued怎麽用?Java QueuedThreadPool.setMaxQueued使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.util.thread.QueuedThreadPool
的用法示例。
在下文中一共展示了QueuedThreadPool.setMaxQueued方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: threadPool
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private ThreadPool threadPool() {
QueuedThreadPool pool = new QueuedThreadPool();
pool.setName("HTTP");
pool.setMinThreads(2);
pool.setMaxThreads(10);
pool.setMaxQueued(50);
return pool;
}
示例2: main
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
* Starts the embedded Jetty server.
*
* @param args
* With -port XX you can specify the port on which the server is running.
* @throws Exception
* Throws an exception if the Jetty server fails to start.
*/
public static void main(final String[] args) throws Exception {
JCommander jCmd = null;
try {
ServerArgs serverArgs = new ServerArgs();
jCmd = new JCommander(serverArgs);
jCmd.parse(args);
Server server = new Server();
BlockingChannelConnector connector = new BlockingChannelConnector();
connector.setPort(serverArgs.port);
if (serverArgs.maxIdleTime > 0) {
connector.setMaxIdleTime(serverArgs.maxIdleTime);
}
if (serverArgs.soLingerTime > 0) {
connector.setSoLingerTime(serverArgs.soLingerTime);
}
if (serverArgs.acceptQueueSize > 0) {
connector.setAcceptQueueSize(serverArgs.acceptQueueSize);
}
server.setConnectors(new Connector[] { connector });
QueuedThreadPool threadPool = new QueuedThreadPool();
if (serverArgs.acceptQueueSize > 0) {
threadPool.setMaxQueued(serverArgs.acceptQueueSize);
}
if (serverArgs.minThreads > 0) {
threadPool.setMinThreads(serverArgs.minThreads);
}
if (serverArgs.maxThreads > 0) {
threadPool.setMaxThreads(serverArgs.maxThreads);
}
server.setThreadPool(threadPool);
ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);
// Add the Guice listener that includes all bindings
handler.addEventListener(new RefAppContextListener());
// Then add the GuiceFilter and configure the server to
// reroute all requests through this filter.
handler.addFilter(GuiceFilter.class, "/*", null);
// Must add DefaultServlet for embedded Jetty.
// Failing to do this will cause 404 errors.
// This is not needed if web.xml is used instead.
handler.addServlet(DefaultServlet.class, "/");
server.setHandler(handler);
// Start the server. Exceptions and not handled here.
server.start();
server.join();
} catch (ParameterException ex) {
jCmd.usage();
}
}