synchronize on logs

This commit is contained in:
Doug MacEachern 2005-09-21 23:00:36 +00:00
parent 7d77935ffe
commit 48c96918d8

View File

@ -27,20 +27,24 @@ public class EventLogThread implements Runnable {
private String logName = "Application";
private long interval = 10 * 1000; // Default to 10 seconds
public static synchronized EventLogThread getInstance(String name) {
EventLogThread instance =
(EventLogThread)logs.get(name);
public static EventLogThread getInstance(String name) {
EventLogThread instance;
synchronized (logs) {
instance = (EventLogThread)logs.get(name);
if (instance == null) {
instance = new EventLogThread();
instance.setLogName(name);
logs.put(name, instance);
}
}
return instance;
}
public static synchronized void closeInstances() {
public static void closeInstances() {
synchronized (logs) {
for (Iterator it = logs.values().iterator();
it.hasNext();)
{
@ -50,6 +54,7 @@ public class EventLogThread implements Runnable {
}
logs.clear();
}
}
public void setInterval(long interval) {
this.interval = interval;