diff --git a/platform/core.execution/src/org/netbeans/core/execution/DefaultSysProcess.java b/platform/core.execution/src/org/netbeans/core/execution/DefaultSysProcess.java index 6d2b6c3d4509..d11e169bdd02 100644 --- a/platform/core.execution/src/org/netbeans/core/execution/DefaultSysProcess.java +++ b/platform/core.execution/src/org/netbeans/core/execution/DefaultSysProcess.java @@ -101,35 +101,4 @@ public void run() { public String getName() { return name; } - - /** destroy the thread group this process was handled from. Not that simple - * as it seems, since the ThreadGroup can't be destroyed from inside. - */ - void destroyThreadGroup(ThreadGroup base) { - new Thread(base, new Destroyer(group)).start(); - } - private static class Destroyer implements Runnable { - private final ThreadGroup group; - Destroyer(ThreadGroup group) { - this.group = group; - } - @Override public void run() { - try { - while (group.activeCount() > 0) { - Thread.sleep(1000); - } - } - catch (InterruptedException e) { - Exceptions.printStackTrace(e); - } - if (!group.isDestroyed()) { - try { - group.destroy(); - } catch (IllegalThreadStateException x) { - // #165302: destroyed some other way? - } - } - } - } - } diff --git a/platform/core.execution/src/org/netbeans/core/execution/ExecutionEngine.java b/platform/core.execution/src/org/netbeans/core/execution/ExecutionEngine.java index 3ae04281f636..b2b7d3a19c11 100644 --- a/platform/core.execution/src/org/netbeans/core/execution/ExecutionEngine.java +++ b/platform/core.execution/src/org/netbeans/core/execution/ExecutionEngine.java @@ -71,9 +71,9 @@ /* table of window:threadgrp */ private static final WindowTable wtable = new WindowTable(); - + /** list of ExecutionListeners */ - private final HashSet executionListeners = new HashSet<>(); + private final Set executionListeners; /** List of running executions */ private final List runningTasks = Collections.synchronizedList(new ArrayList<>(5)); @@ -87,6 +87,8 @@ static final long serialVersionUID =9072488605180080803L; public ExecutionEngine () { + this.executionListeners = new HashSet<>(); + /* SysIn is a class that redirects System.in of some running task to a window (probably OutWindow). SysOut/Err are classes that redirect out/err to the window @@ -134,7 +136,6 @@ public String getRunningTaskName( ExecutorTask task ) { @Override public ExecutorTask execute(String name, Runnable run, final InputOutput inout) { TaskThreadGroup g = new TaskThreadGroup(base, "exec_" + name + "_" + number); // NOI18N - g.setDaemon(true); ExecutorTaskImpl task = new ExecutorTaskImpl(); synchronized (task.lock) { try { @@ -194,7 +195,7 @@ protected final PermissionCollection createPermissions(CodeSource cs, InputOutpu protected final void fireExecutionStarted (ExecutionEvent ev) { runningTasks.add( ev.getProcess() ); @SuppressWarnings("unchecked") - Iterator iter = ((HashSet) executionListeners.clone()).iterator(); + Iterator iter = executionListeners.iterator(); while (iter.hasNext()) { ExecutionListener l = iter.next(); l.startedExecution(ev); @@ -205,12 +206,11 @@ protected final void fireExecutionStarted (ExecutionEvent ev) { protected final void fireExecutionFinished (ExecutionEvent ev) { runningTasks.remove( ev.getProcess() ); @SuppressWarnings("unchecked") - Iterator iter = ((HashSet) executionListeners.clone()).iterator(); + Iterator iter = executionListeners.iterator(); while (iter.hasNext()) { ExecutionListener l = iter.next(); l.finishedExecution(ev); } - ev.getProcess().destroyThreadGroup(base); } static void putWindow(java.awt.Window w, TaskThreadGroup tg) { diff --git a/platform/openide.util/src/org/openide/util/RequestProcessor.java b/platform/openide.util/src/org/openide/util/RequestProcessor.java index eb91719c57bb..d1f8e2ee400e 100644 --- a/platform/openide.util/src/org/openide/util/RequestProcessor.java +++ b/platform/openide.util/src/org/openide/util/RequestProcessor.java @@ -1892,20 +1892,14 @@ static Processor get() { return proc; } } else { - assert checkAccess(TOP_GROUP.getTopLevelThreadGroup()); Processor proc = POOL.pop(); proc.idle = false; - return proc; } } newP = new Processor(); } } - private static boolean checkAccess(ThreadGroup g) throws SecurityException { - g.checkAccess(); - return true; - } /** A way of returning a Processor to the inactive pool. *