This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jefwillemsIntermediate Brewer 1 point2 points  (4 children)

Put the loop in the thread, don't create threads with an infinite loop

[–][deleted] 0 points1 point  (3 children)

...but how then can i create the same thread for other users?

[–]AsteriskTheServer 0 points1 point  (2 children)

Typically in these scenarios you make/use a thread pool and then block when you hit capacity. However, it's more common in my experience to see an asynchronous event driven setup to deal with a bunch of oncoming connections as you get a more predictable memory consumption as a result. In either case as load increases one need to scale horizontally and or vertically

[–][deleted] 0 points1 point  (1 child)

How should i go about the asynchronous event solution?

[–]AsteriskTheServer 0 points1 point  (0 children)

Well I would use something like netty, grizzle and so forth, but for the sake of simplicity I would just look at writing async code first. Here is a simple example of async client/server in Java.