Commit 036fa8d9 authored by yanzg's avatar yanzg

多线程处理配置

parent a88d4829
package com.yanzuoguang.util.extend; package com.yanzuoguang.util.extend;
import com.yanzuoguang.util.log.RunnableLog;
/** /**
* 配置参数 * 配置参数
*/ */
public class Config { public class ConfigBase {
/** /**
* 打印线程相关参数 * 打印线程相关参数
*/ */
public static final boolean PrintThread = false; public static final boolean PrintThread = false;
/**
* 写入日志对象
*/
public static RunnableLog WriteLog;
} }
package com.yanzuoguang.util.log; package com.yanzuoguang.util.log;
import com.yanzuoguang.util.extend.ConfigBase;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -8,8 +10,6 @@ import java.util.HashMap; ...@@ -8,8 +10,6 @@ import java.util.HashMap;
*/ */
public class Log { public class Log {
public static RunnableLog writeLog;
/** /**
* 当前线程缓存的对象 * 当前线程缓存的对象
*/ */
...@@ -95,8 +95,8 @@ public class Log { ...@@ -95,8 +95,8 @@ public class Log {
date.commit(); date.commit();
info.setTime((long) date.getLastSecond()); info.setTime((long) date.getLastSecond());
info.setTotalTime((long) date.getTotalSecond()); info.setTotalTime((long) date.getTotalSecond());
if (writeLog != null) { if (ConfigBase.WriteLog != null) {
writeLog.run(info); ConfigBase.WriteLog.run(info);
} else { } else {
writeLogDefault.run(info); writeLogDefault.run(info);
} }
......
package com.yanzuoguang.util.thread; package com.yanzuoguang.util.thread;
import com.yanzuoguang.util.extend.Config; import com.yanzuoguang.util.extend.ConfigBase;
import com.yanzuoguang.util.log.Log; import com.yanzuoguang.util.log.Log;
import java.util.Date; import java.util.Date;
...@@ -57,7 +57,7 @@ public class ThreadWait { ...@@ -57,7 +57,7 @@ public class ThreadWait {
} }
this.stopPrint(); this.stopPrint();
} }
if (Config.PrintThread) { if (ConfigBase.PrintThread) {
Log.info(ThreadWait.class, "客户端结束时间"); Log.info(ThreadWait.class, "客户端结束时间");
} }
} }
...@@ -78,7 +78,7 @@ public class ThreadWait { ...@@ -78,7 +78,7 @@ public class ThreadWait {
public synchronized void finish() { public synchronized void finish() {
if (this.execute.isFinally()) { if (this.execute.isFinally()) {
this.notify(); this.notify();
if (Config.PrintThread) { if (ConfigBase.PrintThread) {
Log.info(ThreadWait.class, "客户端结束时间"); Log.info(ThreadWait.class, "客户端结束时间");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment