Communication between the many concurrent programming thread

1. reordering concept

   A.cpu order to optimize code execution will not have data dependencies do reordering. Code execution order may change, but the results will not perform any change.

   B.as-if-serial: No matter how do reordering, it aims to improve the degree of parallelism, but does not affect the normal results.

   C. reordering encountered in multithreading

2.wait () and notify ()

   A.wait () wait: thread to wait, and release the lock resources

   B.noftify () wake: wake of the current object lock pool is waiting thread

   C. Note: Be sure to use in synchronized, and is held by the same lock.

   D.sleep will not release the lock

 

Guess you like

Origin www.cnblogs.com/it-szp/p/11470285.html
Recommended