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;
        }
    }
  • 相关阅读:
    简单二分求解(木板补漏问题)
    switch语句和for循环
    JAVA运算符和优先级
    JAVA数据类型
    JAVA基础
    JAVA开发环境
    linux配置IP地址
    LVM逻辑分区
    用户和用户组
    第一天
  • 原文地址:https://www.cnblogs.com/exmyth/p/13806256.html
Copyright © 2011-2022 走看看