diff options
author | Denis Lila <[email protected]> | 2011-05-03 09:14:16 -0400 |
---|---|---|
committer | Denis Lila <[email protected]> | 2011-05-03 09:14:16 -0400 |
commit | bbbb38b7c109881d023a8a183b367f3defdbdb96 (patch) | |
tree | 98c42722fe989d3577552b3e51ad3af44a07b126 /netx | |
parent | 44e1d8f721f0d1428e9f34573e9964e6287d5e64 (diff) |
Fix useless thread group creation.
Diffstat (limited to 'netx')
-rw-r--r-- | netx/net/sourceforge/jnlp/NetxPanel.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/netx/net/sourceforge/jnlp/NetxPanel.java b/netx/net/sourceforge/jnlp/NetxPanel.java index e8d43cd..59c3ce0 100644 --- a/netx/net/sourceforge/jnlp/NetxPanel.java +++ b/netx/net/sourceforge/jnlp/NetxPanel.java @@ -27,7 +27,9 @@ import net.sourceforge.jnlp.runtime.AppletInstance; import net.sourceforge.jnlp.runtime.JNLPRuntime; import java.net.URL; +import java.util.HashMap; import java.util.Hashtable; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -49,8 +51,9 @@ public class NetxPanel extends AppletViewerPanel { // We use this so that we can create exactly one thread group // for all panels with the same uKey. - private static final ConcurrentMap<String, ThreadGroup> uKeyToTG = - new ConcurrentHashMap<String, ThreadGroup>(); + private static final Map<String, ThreadGroup> uKeyToTG = + new HashMap<String, ThreadGroup>(); + private static final Object TGMapMutex = new Object(); // This map is actually a set (unfortunately there is no ConcurrentSet // in java.util.concurrent). If KEY is in this map, then we know that @@ -95,8 +98,12 @@ public class NetxPanel extends AppletViewerPanel { // when this was being done (incorrectly) in Launcher, the call was // new AppThreadGroup(mainGroup, file.getTitle()); - ThreadGroup tg = new ThreadGroup(Launcher.mainGroup, this.documentURL.toString()); - uKeyToTG.putIfAbsent(this.uKey, tg); + synchronized(TGMapMutex) { + if (!uKeyToTG.containsKey(this.uKey)) { + ThreadGroup tg = new ThreadGroup(Launcher.mainGroup, this.documentURL.toString()); + uKeyToTG.put(this.uKey, tg); + } + } } // overloaded constructor, called when initialized via plugin @@ -210,7 +217,9 @@ public class NetxPanel extends AppletViewerPanel { } public ThreadGroup getThreadGroup() { - return uKeyToTG.get(uKey); + synchronized(TGMapMutex) { + return uKeyToTG.get(uKey); + } } public void createNewAppContext() { |