synchronize on logs
This commit is contained in:
parent
7d77935ffe
commit
48c96918d8
@ -27,20 +27,24 @@ 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);
|
|
||||||
|
synchronized (logs) {
|
||||||
|
instance = (EventLogThread)logs.get(name);
|
||||||
|
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new EventLogThread();
|
instance = new EventLogThread();
|
||||||
instance.setLogName(name);
|
instance.setLogName(name);
|
||||||
logs.put(name, instance);
|
logs.put(name, instance);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void closeInstances() {
|
public static void closeInstances() {
|
||||||
|
synchronized (logs) {
|
||||||
for (Iterator it = logs.values().iterator();
|
for (Iterator it = logs.values().iterator();
|
||||||
it.hasNext();)
|
it.hasNext();)
|
||||||
{
|
{
|
||||||
@ -50,6 +54,7 @@ public class EventLogThread implements Runnable {
|
|||||||
}
|
}
|
||||||
logs.clear();
|
logs.clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setInterval(long interval) {
|
public void setInterval(long interval) {
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
|
Loading…
Reference in New Issue
Block a user