multithreading - Java yield() a thread with synchronized block to a higher Priority thread also with a synchronized block. -


from understand, yield() on thread not release lock thread. if there 2 threads , both of them have synchronized block in thread pool, lower priority , b higher priority. if thread running , yield() called in a, thread b run scheduler. because currently, thread still holding lock, thread b can not go critical block? understanding, cause deadlock?

please let me know miss something?

thanks much:)

there confusion here.

  1. there no deadlock, because there 1 lock. need @ least 2 locks deadlock.

  2. yield() nothing. see javadoc.

  3. at time, possibly including when call yield(), higher-priority thread block trying obtain lock. no longer eligible execution. scheduler have schedule else runnable.

  4. meanwhile lower-priority thread remains runnable (i.e. eligible execution), scheduled sooner or later, continues execute. sooner or later release lock, allow higher-priority thread acquire , continue execution.


Comments