ecb1fb543c86d16b5a0b1f85da587f8f6cfc5e2f.svn-base
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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;
}
}