ecb1fb543c86d16b5a0b1f85da587f8f6cfc5e2f.svn-base 1.46 KB
package com.thinkgem.jeesite.modules.reg.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 

public class Singleton {
	protected Logger logger = LoggerFactory.getLogger(getClass());
	//类加载时就初始化
    private static final Singleton instance = new Singleton();
    
    private Singleton(){}

    public static Singleton getInstance(){
        return instance;
    }
	private  Boolean rr = false;//登簿变量
	private  Boolean bj = false;//办结变量
	private  Boolean zt = false;//状态变量
	 
	public Boolean useRr() {
		if(rr) {
			return false;
		} 
		rr = true;
		String name = Thread.currentThread().getName();
		logger.info("线程{}得到锁",name); 
		return true;
	} 
	
	public void closeRr() {
		String name = Thread.currentThread().getName();
		logger.info("线程{}释放锁",name); 
		rr = false;
	}
	 
	
	public Boolean useBj() {
		if(bj) {
			return false;
		} 
		bj = true;
		String name = Thread.currentThread().getName();
		logger.info("线程{}得到锁",name); 
		return true;
	} 
	
	public void closeBj() {
		String name = Thread.currentThread().getName();
		logger.info("线程{}释放锁",name); 
		bj = false;
	}
	
	public Boolean useZt() {
		if(zt) {
			return false;
		} 
		zt = true;
		String name = Thread.currentThread().getName();
		logger.info("线程{}得到锁",name); 
		return true;
	} 
	
	public void closeZt() {
		String name = Thread.currentThread().getName();
		logger.info("线程{}释放锁",name); 
		zt = false;
	}

}