Sleep mode processing in java service

I have a difficult problem like below. - we have a real-time system with the requirement of a large number of threads. To optimize performance, we are thinking about the next design.

  • create a thread pool executor with the maximum number of threads
  • each thread is used to create a scheduled executor service.
  • tasks are now assigned to these executing services evenly based on load

  • BUT the biggest problem is that if one of the tasks in the queue contains sleep mode (for several seconds), it blocks the corresponding flow of Schedule artist services for this duration, and then all the following tasks in this queue.

  • In this regard, please suggest me how to suspend the task with a dream or somehow redefine the dream and reconnect to the task again.

Thanks in advance

+3
source share
2 answers

Assuming I understand your question, your Schedule Executor service threads have an extreme requirement, but actual workers may sleep for an unknown period of time, possibly delaying the execution of Schedule Executors. From your description, I guess that you want the task that needs to sleep to actually stop, save the progress information, and then ask yourself so that the rest of the work will be rescheduled in the future. You would have to build this in your application architecture.

, , , , .

, , .

+1

, . , .

, 2 ( ), . , .

- , , , ( , ).

. , , , .

+1

Source: https://habr.com/ru/post/1719188/


All Articles