NetBeans / Java / New hint: Thread.sleep called in loop

后端 未结 4 1391
-上瘾入骨i
-上瘾入骨i 2020-12-08 09:10

In NetBeans, there\'s a new hint that says: Thread.sleep called in loop.

Question 1: How/when can it be a problem to sleep in a loo

4条回答
  •  爱一瞬间的悲伤
    2020-12-08 09:50

    How/when can it be a problem to sleep in a loop?
    People sometimes employ it in place of proper synchronization methods (like wait/notify).

    If it's a problem, what should I do instead?
    Depends on what you're doing. Although it's dificult for me to imagine situation where doing this is the best approach, I guess that's possible too.

    You can check Sun's concurrency tutorial on this subject.

提交回复
热议问题