Why can't you use notifyAll () in an instance of Thread?

I am using a source code analyzer that pointed out that notifyAll () should not be called on an instance of Thread. I am trying to formulate this for guidance, but I cannot come up with an explanation. Can someone help me?

By the way, this is inherited code, so I am not responsible for the design decision!

+4
source share
2 answers

It looks like the SONAR message you see is this :

The methods "wait (...)", "notify ()" and "notifyAll ()" should never be called in instances of Thread squid: S2236

Sonar :

Thread wait (...), notify() notifyAll() , Java Object . Thread:

. , , wait (...) ? ?

JVM (BLOCKED, WAITING,...), JVM.

, , API Java:

, wait, notify notifyAll Thread.

. , . , , , .

, - JVM, (, .) - , , , , . Thread, , .

, , ? SONAR - , , , .

+7

Thread. . wait/notifyAll , concurrency , Thread , Thread wait/notify .

0

All Articles