Happen before
https://stackoverflow.com/questions/14329064/synchronized-and-the-scope-of-visibility
Atomic
http://www.jianshu.com/p/0f1b4ae625e5
Monitor/Condition
Object, wait, notify, notifiyAll (the last two must be called when we get the object lock)
ReentranceLock, Condition (the later one must be called when we get the reentrance lock). The condition use “LockSupport.park and unpark” to suspend thread and wakeup thread
Lock and Sync
See http://www.cnblogs.com/wanly3643/p/3835839.html
Lock —-> AbstractQueuedSynchronizer —> setState to communicate between threads, put waiting threads to a waiting list, use park to suspend threads and unpark to wake up threads
ReentrantLock —-> Sync/FairSync/NonFairSync
ReentrantReadWriteLock —> ReadLock/WriteLock, Sync/FairSync/NonFairSync
Semphore –> Sync/FairSync/NonFairSync, allow limit number of share locking
ConcurrentHashMap
http://www.cnblogs.com/wanly3643/category/437878.html
Use volatile
Sync only in one bucket
BlockingQueue
They are using ReentrantLock and Condition to do syncing
BlockingQueue use lock and condition to implement the consumer and producer scenario
ArrayBlockingQueue needs one lock while LInkedBlockingQueue needs two
See notes in “Collection and Map” for all BlockingQueue classes
Thread State:
https://www.geeksforgeeks.org/lifecycle-and-states-of-a-thread-in-java/
Executor

- How ThreadPoolExecutor controls the threads:
http://www.jianshu.com/p/65da61177eed
Submit process:
Submit(Runnable) ---> execute(FutureTask(runnable)) --> threadpool call runWorkers() --> FutureTask.run --\> FutureTask.finish --\> unpark(waiting client threads) --> worker thread continue to take task from workQueue
ClientThread --\> FutureTask.get --> awaitDone --\> park(client thread), waiting to be unparked by FutureTask.finish
How ScheduledThreadPoolExecutor works:
Same as ThreadPoolExecutor, but use a DelayWorkQueue as workQueue, which as deplay polling task.
DelayWorkQueue contains ScheduleFutureTask, which is a FutureTask that will can check the delayTime before each run and add itself back to workQueue if it is set to repeatly run.
DelayWorkQueue is actually similar to PriorityQueue, which maintains a binary heap, which compare by each element’s delay time.
ForkJoinPool
See http://www.bijishequ.com/detail/520567?p=37 for implementation detail
Some tips:
The pool maintains an array of WorkQueue
Each workQueue contains a ForkJoinThread, which is actually a thread can run to steal jobs and run its own taskQueue
Each taskQueue is an array of ForkJoinTask, which is a FutureTask
Each ForkJoinThread will get its own job from its queue using FILO, but steal job from other thread’s queue using FIFO