aboutsummaryrefslogtreecommitdiff
path: root/src/IvyWatcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/IvyWatcher.java')
-rwxr-xr-xsrc/IvyWatcher.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/IvyWatcher.java b/src/IvyWatcher.java
index 1e33302..54eca11 100755
--- a/src/IvyWatcher.java
+++ b/src/IvyWatcher.java
@@ -14,6 +14,8 @@
* thing.
*
* CHANGELOG:
+ * 1.2.16
+ * - now uses the synchronized wrappers of the Java API for all collections
* 1.2.15
* - allows the fine tuning of the IvyClient socket buffersize using
* IVY_BUFFERSIZE property
@@ -83,7 +85,9 @@ package fr.dgac.ivy ;
import java.lang.Thread;
import java.net.*;
import java.io.*;
-import java.util.Hashtable;
+import java.util.Collections;
+import java.util.Map;
+import java.util.HashMap;
import java.util.regex.*;
class IvyWatcher extends Thread {
@@ -295,17 +299,17 @@ class IvyWatcher extends Thread {
* checks if there is already a broadcast received from the same address
* on the same port
*
- * regoes static ...
*/
- //private static Hashtable alreadySocks=new Hashtable();
- private Hashtable<String,Integer> alreadySocks=new Hashtable<String,Integer>();
- private synchronized boolean alreadyBroadcasted(String s,int port) {
+ private Map<String,Integer> alreadySocks=Collections.synchronizedMap(new HashMap<String,Integer>());
+ private boolean alreadyBroadcasted(String s,int port) {
// System.out.println("DEBUUUUUUUG " + s+ ":" + port);
if (s==null) return false;
- Integer i = alreadySocks.get(s);
- if (((i!=null)&&(i.compareTo(port))==0)) return true;
- alreadySocks.put(s,port);
- return false;
+ synchronized (alreadySocks) {
+ Integer i = alreadySocks.get(s);
+ if (((i!=null)&&(i.compareTo(port))==0)) return true;
+ alreadySocks.put(s,port);
+ return false;
+ }
}
/*