且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

servlet 多线程

更新时间:2023-12-04 12:35:04

每个 HTTP 连接使用一个线程(这与服务器使用 NIO 时不完全一样,但您明白了).您的浏览器显然在两个选项卡中都使用相同的 HTTP 连接.生成两个不同的浏览器实例(例如 Firefox 和 Chrome),您会看到它按您预期的方式工作.

It's using one thread per HTTP connection (it's not exactly that when the server uses NIO, but you got the point). Your browser is apparently using the same HTTP connection in both tabs. Spawn two different browser instances (e.g. Firefox and Chrome) and you'll see that it works the way you expected.