java - notify() in synchronized block -


i have found blow code in project. cant understand why notify() method in synchronized block .

synchronized(this){   notify(); } 

is code logical , if real purpose ?

notify( ) wakes first thread called wait( ) on same object.

class threadb extends thread{ int total; @override public void run(){     synchronized(this){         for(int i=0; i<100 ; i++){             total += i;         }         notify();     } } 

like above example, use notify send information message(hey finished work, wake !) other thread waiting. @ question, not meaningful


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -