synchronize on logs
This commit is contained in:
parent
7d77935ffe
commit
48c96918d8
@ -27,28 +27,33 @@ public class EventLogThread implements Runnable {
|
|||||||
private String logName = "Application";
|
private String logName = "Application";
|
||||||
private long interval = 10 * 1000; // Default to 10 seconds
|
private long interval = 10 * 1000; // Default to 10 seconds
|
||||||
|
|
||||||
public static synchronized EventLogThread getInstance(String name) {
|
public static EventLogThread getInstance(String name) {
|
||||||
EventLogThread instance =
|
EventLogThread instance;
|
||||||
(EventLogThread)logs.get(name);
|
|
||||||
|
|
||||||
if (instance == null) {
|
synchronized (logs) {
|
||||||
instance = new EventLogThread();
|
instance = (EventLogThread)logs.get(name);
|
||||||
instance.setLogName(name);
|
|
||||||
logs.put(name, instance);
|
if (instance == null) {
|
||||||
|
instance = new EventLogThread();
|
||||||
|
instance.setLogName(name);
|
||||||
|
logs.put(name, instance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void closeInstances() {
|
public static void closeInstances() {
|
||||||
for (Iterator it = logs.values().iterator();
|
synchronized (logs) {
|
||||||
it.hasNext();)
|
for (Iterator it = logs.values().iterator();
|
||||||
{
|
it.hasNext();)
|
||||||
EventLogThread eventLogThread =
|
{
|
||||||
(EventLogThread)it.next();
|
EventLogThread eventLogThread =
|
||||||
eventLogThread.doStop();
|
(EventLogThread)it.next();
|
||||||
|
eventLogThread.doStop();
|
||||||
|
}
|
||||||
|
logs.clear();
|
||||||
}
|
}
|
||||||
logs.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInterval(long interval) {
|
public void setInterval(long interval) {
|
||||||
|
Loading…
Reference in New Issue
Block a user