How to try Project Loom and would Project Loom replace Threads in java.net.Serve

Started by jenit739, December 08, 2021, 03:58:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jenit739

Hi
Scalability is OS-dependent as ServerSocket that handle multiple connections use Threads. In websocket, you would need 1 thread for 1 connection. In other words, scalability is bad if you use IO ServerSocket. Therefore, I believe most people would use NIO for the WebSocket server, but maybe stick with IO for HTTP server.
What do you think? Would porting to virtual threads e.g this snippet of code will be easy? `SessionHandler implements Runnable`.

```

SessionHandler handler = new SessionHandler(socket);

new Thread(handler).start();