📄 testglobal.java
字号:
package com.sms.platform.switchcenter.inner.reportrespqueue;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.PatternLayout;
import com.pub.util.FileUtils;
public class TestGlobal {
static {
PatternLayout layout = null;
ConsoleAppender consoleAppender = null;
layout = new PatternLayout("%d %5p [%t] (%F:%L) - %m%n");
consoleAppender = new ConsoleAppender(layout, "System.out");
org.apache.log4j.BasicConfigurator.configure(consoleAppender);
}
ReportRespQueue respQueue = null;
private static TestGlobal _instance = null;
// 构造函数
private TestGlobal() throws Exception {
respQueue = new ReportRespQueue();
String path = "";
try {
path = FileUtils.createDirectory("c:/temp/");
} catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
String name = "respQueue";
if (respQueue.open(path, name) != 0)
return;
}
/**
* 单例模式获得实例的方法
*
* @return Global
*/
public static synchronized TestGlobal getInstance() {
if (_instance == null) {
try {
_instance = new TestGlobal();
} catch (Throwable ex) {
ex.printStackTrace();
}
}
return _instance;
}
public ReportRespQueue getRespQueue() {
return respQueue;
}
public void setRespQueue(ReportRespQueue respQueue) {
this.respQueue = respQueue;
}
public static void main(String [] args){
TestPop o = new TestPop();
o.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
TestPut p = new TestPut();
p.start();
// for(int i = 0 ; i < 100 ; i++){
// ClearQueueThread ct = new ClearQueueThread();
// ct.start();
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// // TODO 自动生成 catch 块
// e.printStackTrace();
// }
// }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -