V
V
vados092017-03-21 12:09:55
Java
vados09, 2017-03-21 12:09:55

How to assign a separate thread to each new connected user?

Good afternoon, the task is for each new connected client to allocate its own data processing stream, with repeated requests, throw all the data into this stream. When the data is processed, and new ones do not come, the stream will end. Tell me how can this be implemented?? I tried to create a map and make a pair of id-threads for each new user, but in the end, one thread is still processing all connections.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cane, 2017-03-30
@cane

From the controller, you can execute asynchronous service methods. In Spring, such methods are annotated with the @Async annotation . The request will be completed and the task will continue.
To change the job, you can use some kind of queue or use the event system. see ApplicationEvent .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question