More efficient way for pausing loop wanted

后端 未结 4 1248
后悔当初
后悔当初 2020-11-27 22:03

Is it possible to rewrite this code for better working with processor? I have a class, which does some tasks with fixed periodicy in a separate thread. Sometimes this proces

4条回答
  •  被撕碎了的回忆
    2020-11-27 22:32

    Your best options are to either use wait()/notify() or to simply switch to ScheduledExecutorService

    Proper wait()/notify() usage can be tricky. I highly recommend "Java Concurrency in Practice" to learn more about threading.

提交回复
热议问题