Phase 1 Language Basics + Advanced _1-3-Java language senior _05- abnormal and multi-threaded Section 3 thread synchronization mechanism _3_ principle of thread-safety issues arising _



Explain the principles of thread safety problems of
three threads t0 t1 t2. T0 plus the implementation of the right to grab the cpu


t0 grab executive power cpu's. But if statement went where. Implementation of sleep, lost the right to perform

hypothesis t2 grab executive power also to execute the run method





t2 woke up



the issue of duplicate tickets. Three threads to simultaneously execute this line of code output

to sum up




 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11260431.html