jersey - How to approach the dispatching of open sockets to threads in Java? -
we need create listeningdispatcher accepts connections on port p n clients (for local, identified port, address later). approach put .accept() call, retrieve socket, start new thread , let handle message socket. if have n clients in our distributed system (broadcast based, logical token ring), keep n threads, n sockets.
my mate arguing keep many threads open , it's better start new thread on every new connection instead of keeping thread running, closing socket , stop thread after message recieved. way, use less threads have create new socket every message.
i think degrade communication because takes time open new socket.
consider system must scalable , has heavy communication part, because every event broadcasted every client.
note: can't use threadpools
my approach put .accept() call, retrieve socket, start new thread , let handle message socket.
don't start new thread. use thread pool , reuse threads.
this way, use less thread have create new socket every message
for each client use different client socket via accept
. sentence not make sense
Comments
Post a Comment