Skip to content

Commit

Permalink
Update DefaultPoolExecutor.java
Browse files Browse the repository at this point in the history
在指令重排序下,单例双重校验不安全,用volatile可以禁止指令重排序
  • Loading branch information
hanshengjian authored Oct 31, 2018
1 parent 8e3a4ca commit bb75001
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DefaultPoolExecutor extends ThreadPoolExecutor {
private static final int MAX_THREAD_COUNT = INIT_THREAD_COUNT;
private static final long SURPLUS_THREAD_LIFE = 30L;

private static DefaultPoolExecutor instance;
private static volatile DefaultPoolExecutor instance;

public static DefaultPoolExecutor getInstance() {
if (null == instance) {
Expand Down

0 comments on commit bb75001

Please sign in to comment.