zoukankan      html  css  js  c++  java
  • PpcProcessResult

    @Data
    @Accessors(chain = true)
    public class PpcProcessResult {
        public static volatile int globalThreadStatus = DEFAULT_PPC_THREAD_STATUS;
        private String host;
        private Integer port;
        private Boolean isDebug;
        private Integer threadStatus;
    
        public synchronized static void setBusy(int tid){
            globalThreadStatus = globalThreadStatus | (1 << tid);
        }
    
        public synchronized static void setIdle(int tid){
            globalThreadStatus = globalThreadStatus & (~(1 << tid));
        }
    
        public synchronized static boolean isBusy(int tid){
            return (1 << tid) == ((1 << tid) & globalThreadStatus);
        }
    
        public synchronized static Integer getIdleTid(){
            if(globalThreadStatus >= BUSY_PPC_THREAD_STATUS){
                return null;
            }
            int tid = 1;
            //如果繁忙,则自增继续,直到取出status等于0
            int status = 1 << tid;
            while ((status & globalThreadStatus) != 0){
                status = status << 1;
                tid++;
            }
            return tid;
        }
    }
  • 相关阅读:
    公共控件
    winform 窗口 属性
    ADO
    笔记备忘
    常识 备忘
    Symbol
    Promise
    定义类 属性 方法 执行
    x is string str ======x is string 变量名
    ManualResetEvent多线程进行,全部完成后,回调
  • 原文地址:https://www.cnblogs.com/exmyth/p/13806256.html
Copyright © 2011-2022 走看看