public class ControlThreadRun { private static final AtomicBoolean downing=new AtomicBoolean(false); public final static boolean isDowning(){ return downing.get(); } public static Boolean usable(){ return downing.compareAndSet(false, true); } public static void notUsable(){ downing.set(false); } }
在其他類的代碼快直接可以使用這個類中的方法進行代碼塊訪問控制