diff --git a/bindings/java/src/net/hyperic/sigar/win32/EventLogThread.java b/bindings/java/src/net/hyperic/sigar/win32/EventLogThread.java index da7e40f7..9abd26aa 100644 --- a/bindings/java/src/net/hyperic/sigar/win32/EventLogThread.java +++ b/bindings/java/src/net/hyperic/sigar/win32/EventLogThread.java @@ -20,21 +20,37 @@ public class EventLogThread implements Runnable { Logger.getLogger(EventLogThread.class.getName()); private Thread thread = null; - private static EventLogThread instance = null; + private static HashMap logs = new HashMap(); private boolean shouldDie = false; private Set notifiers = Collections.synchronizedSet(new HashSet()); private String logName = "Application"; private long interval = 10 * 1000; // Default to 10 seconds - public static synchronized EventLogThread getInstance() { + public static synchronized EventLogThread getInstance(String name) { + EventLogThread 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() { + for (Iterator it = logs.values().iterator(); + it.hasNext();) + { + EventLogThread eventLogThread = + (EventLogThread)it.next(); + eventLogThread.doStop(); + } + logs.clear(); + } + public void setInterval(long interval) { this.interval = interval; } @@ -140,7 +156,6 @@ public class EventLogThread implements Runnable { } public static void main(String[] args) { - HashMap logs = new HashMap(); if (args.length == 0) { args = new String[] { "System", "Application", "Security" @@ -161,13 +176,11 @@ public class EventLogThread implements Runnable { for (int i=0; i