[Schmitzm-commits] r2081 - trunk/schmitzm-core/src/main/java/de/schmitzm/lang
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Sat Sep 8 22:22:42 CEST 2012
Author: alfonx
Date: 2012-09-08 22:22:42 +0200 (Sat, 08 Sep 2012)
New Revision: 2081
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/lang/TimedConcurrentHashMap.java
Log:
javax.swing.Timer gegen java.util.Timer ausgetauscht, da ich damit eine Execption auf einem System ohne X11 vermute:
Exception in thread "TimerQueue" java.lang.InternalError: Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:110)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:119)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at java.awt.Toolkit$2.run(Toolkit.java:870)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:862)
at java.awt.Toolkit.getEventQueue(Toolkit.java:1732)
at java.awt.EventQueue.invokeLater(EventQueue.java:1208)
at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1290)
at javax.swing.Timer$1.run(Timer.java:613)
at javax.swing.Timer$1.run(Timer.java:611)
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/TimedConcurrentHashMap.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/TimedConcurrentHashMap.java 2012-09-05 21:51:01 UTC (rev 2080)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/TimedConcurrentHashMap.java 2012-09-08 20:22:42 UTC (rev 2081)
@@ -1,13 +1,11 @@
package de.schmitzm.lang;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
-import javax.swing.Timer;
-
/**
* Erweiterung der {@link LimitedHashMap}. Erlaubt es in Millisekunden anzugeben, wie lange ein Eintrag gültig ist.
* Diese Klasse ist eine Kopie von {@link TimedHashMap}, extended aber nicht {@link HashMap}, sondern
@@ -55,25 +53,42 @@
// Timeour ms Nach dem letzten put die komplette hashmap leeren.
if (cleanTask != null) {
- cleanTask.stop();
+ // cleanTask.stop(); javax.swing.Timer
+ cleanTask.cancel();
}
- cleanTask = new Timer(timeout + 1, new ActionListener() {
+ // javax.swing.Timer
+ // cleanTask = new Timer(timeout + 1, new ActionListener() {
+ //
+ // @Override
+ // public void actionPerformed(ActionEvent arg0) {
+ // clear();
+ // inputTimes.clear();
+ // if (cleanTask != null) {
+ // cleanTask.stop();
+ // cleanTask = null;
+ // }
+ // }
+ //
+ // });
+ cleanTask = new Timer();
+ cleanTask.schedule(new TimerTask() {
+
@Override
- public void actionPerformed(ActionEvent arg0) {
+ public void run() {
clear();
inputTimes.clear();
if (cleanTask != null) {
- cleanTask.stop();
+ cleanTask.cancel();
cleanTask = null;
}
}
+ }, timeout);
- });
- cleanTask.setInitialDelay(timeout);
- cleanTask.setRepeats(false);
- cleanTask.start();
+ // cleanTask.setInitialDelay(timeout);
+ // cleanTask.setRepeats(false);
+ // cleanTask.start();
inputTimes.put(key, Long.valueOf(System.currentTimeMillis()));
return super.put(key, value);
@@ -123,7 +138,10 @@
@Override
public void clear() {
super.clear();
- if (cleanTask != null)
- cleanTask.stop();
+ if (cleanTask != null) {
+
+ cleanTask.cancel();
+ // cleanTask.stop();
+ }
}
}
More information about the Schmitzm-commits
mailing list