默认情况下,Jetty非阻塞? [英] Jetty nonblocking by default?

查看:157
本文介绍了默认情况下,Jetty非阻塞?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我, 默认情况下,Jetty是非阻止性Web服务器吗?

Please tell me, Is Jetty non-blocking web server by default or not?

例如,下面的代码将Jetty作为非阻塞Web服务器运行?

For example, this code below runs Jetty as non-blocking web server?

Server server = new Server(8080);

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

context.setContextPath("/");

server.setHandler(context);

context.addServlet(new ServletHolder(new MyServlet()),"/*");

server.start();

server.join();

谢谢!

推荐答案

这取决于您使用的Jetty版本.

It depends on which version of Jetty you're using.

  • 在Jetty 6中,"Server(int port)"构造函数将在该端口上打开阻塞连接器.
  • 在Jetty 7中,"Server(int port)"构造函数在该端口上打开一个非阻塞连接器.

如果您真的很在意这种行为,那么最好自己配置连接器,而不要依赖于该便捷构造函数.

If you really care about the behaviour, you're better off configuring the connector yourself, rather than relying on that convenience constructor.

这篇关于默认情况下,Jetty非阻塞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆