diff options
author | Stephan Herrmann | 2010-06-27 11:07:49 +0000 |
---|---|---|
committer | Stephan Herrmann | 2010-06-27 11:07:49 +0000 |
commit | 244bab6ebcc315a044ab843b216869ef68ac87bb (patch) | |
tree | 20b58ded9b5c3adc419f0ed92b16a54682863081 /othersrc | |
parent | ccfcc23bd750a02bf90a699f6619b20f208ed5d6 (diff) | |
download | org.eclipse.objectteams-244bab6ebcc315a044ab843b216869ef68ac87bb.tar.gz org.eclipse.objectteams-244bab6ebcc315a044ab843b216869ef68ac87bb.tar.xz org.eclipse.objectteams-244bab6ebcc315a044ab843b216869ef68ac87bb.zip |
Fixes for Bug 316696 - [otre] OTRE doesn't know about all threads
(see comment 2)
also includes deployment issues.
Diffstat (limited to 'othersrc')
-rw-r--r-- | othersrc/OTRE/src/org/objectteams/Team.java | 6 | ||||
-rw-r--r-- | othersrc/OTRE/src/org/objectteams/TeamThreadManager.java | 28 |
2 files changed, 26 insertions, 8 deletions
diff --git a/othersrc/OTRE/src/org/objectteams/Team.java b/othersrc/OTRE/src/org/objectteams/Team.java index fe0a5145a..5feaccacf 100644 --- a/othersrc/OTRE/src/org/objectteams/Team.java +++ b/othersrc/OTRE/src/org/objectteams/Team.java @@ -16,7 +16,6 @@ **********************************************************************/ package org.objectteams; -import java.awt.EventQueue; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -174,9 +173,6 @@ public /* team */ class Team implements ITeam { synchronized (this._OT$registrationLock) { boolean shouldUnregister= false; synchronized(this) { - if (_OT$globalActive && EventQueue.isDispatchThread()) { - System.err.println("Warning: Deactivation for the AWT-Event-Thread is not effective right now!"); - } if (thread.equals(ALL_THREADS)) { _OT$globalActive = false; TeamThreadManager.removeGlobalActiveTeam(this); @@ -313,8 +309,6 @@ public /* team */ class Team implements ITeam { * {@inheritDoc} */ public boolean isActive(Thread thread) { - if (_OT$globalActive && EventQueue.isDispatchThread()) - return true; if (thread.equals(ALL_THREADS)) { return _OT$globalActive; } diff --git a/othersrc/OTRE/src/org/objectteams/TeamThreadManager.java b/othersrc/OTRE/src/org/objectteams/TeamThreadManager.java index ce1b174a6..debccb712 100644 --- a/othersrc/OTRE/src/org/objectteams/TeamThreadManager.java +++ b/othersrc/OTRE/src/org/objectteams/TeamThreadManager.java @@ -38,10 +38,11 @@ public class TeamThreadManager { private static HashSet<Thread> existingThreads = new HashSet<Thread>(); public static boolean newThreadStarted(boolean isMain, Thread parent) { - if (!isMain && (new Exception().getStackTrace().length > 3)) + Thread currentThread = Thread.currentThread(); + // already registered? + if (existingThreads.contains(currentThread)) return false; // workaround for application hang on Mac OS with Apple JVM: - Thread currentThread = Thread.currentThread(); if (System.getProperty("os.name").startsWith("Mac")) if (currentThread.getName().equals("AWT-Shutdown")) return false; @@ -50,6 +51,11 @@ public class TeamThreadManager { ITeam[] inheritableTeams; synchronized (TeamThreadManager.class) { existingThreads.add(currentThread); + if (isMain) { + for (Thread thread : fetchSystemThreads(currentThread)) + if (thread != null) + existingThreads.add(thread); + } globalTeams = globalActiveTeams.toArray(new ITeam[globalActiveTeams.size()]); inheritableTeams = teamsWithActivationInheritance.keySet().toArray(new ITeam[teamsWithActivationInheritance.size()]); @@ -63,6 +69,24 @@ public class TeamThreadManager { t.activate(currentThread); // pass activation from parent to child thread return true; } + + /* Fetch all existing threads existing at this point in time. Result array is padded with nulls. */ + private static Thread[] fetchSystemThreads(Thread currentThread) { + ThreadGroup group = currentThread.getThreadGroup(); + { + ThreadGroup parentGroup; + while ((parentGroup= group.getParent()) != null) + group = parentGroup; + } + int size = group.activeCount(); + Thread[] allThreads; + do { + size += 2; + allThreads = new Thread[size]; + } while (group.enumerate(allThreads) == size); + return allThreads; + } + public static void threadEnded() { ITeam[] teamsToDeactivate = internalThreadEnded(); // + remove per thread activation: |