Computer Hope

Software => Computer programming => Topic started by: jenit739 on December 08, 2021, 03:58:25 AM

Title: How to try Project Loom and would Project Loom replace Threads in java.net.Serve
Post by: jenit739 on December 08, 2021, 03:58:25 AM
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();