You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by bw...@apache.org on 2025/12/20 04:30:57 UTC
(netbeans) 01/01: cleanup: remove deprecated TheadGroup methods
This is an automated email from the ASF dual-hosted git repository.
bwalker pushed a commit to branch cleanup_threadgroup_method_usage
in repository https://gitbox.apache.org/repos/asf/netbeans.git
commit 0cf9d33cd01d23b9c9cc86859b95185d2c5f8c66
Author: Brad Walker <bw...@musings.com>
AuthorDate: Wed Dec 17 18:14:29 2025 -0700
cleanup: remove deprecated TheadGroup methods
desc: The ThreadGroup class is an artificate of by-gone days. The ability to destroy a thread group and the concept of a destroyed thread group no longer exists. Several of the methods are null functions as well as marked for removal. This cleans up the usage of these methods.
---
.../netbeans/core/execution/DefaultSysProcess.java | 31 ----------------------
.../netbeans/core/execution/ExecutionEngine.java | 31 +++++++++++-----------
.../src/org/openide/util/RequestProcessor.java | 6 -----
3 files changed, 16 insertions(+), 52 deletions(-)
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 6d2b6c3d450..d11e169bdd0 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 @@ final class DefaultSysProcess extends ExecutorTask {
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 3ae04281f63..9fbec8948fa 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 @@ public final class
/* table of window:threadgrp */
private static final WindowTable wtable = new WindowTable();
-
+
/** list of ExecutionListeners */
- private final HashSet<ExecutionListener> executionListeners = new HashSet<>();
+ private final Set<ExecutionListener> executionListeners;
/** List of running executions */
private final List<ExecutorTask> runningTasks = Collections.synchronizedList(new ArrayList<>(5));
@@ -87,6 +87,8 @@ public final class
static final long serialVersionUID =9072488605180080803L;
public ExecutionEngine () {
+ this.executionListeners = Collections.synchronizedSet(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 final class
@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 {
@@ -193,24 +194,25 @@ public final class
/** fires event that notifies about new process */
protected final void fireExecutionStarted (ExecutionEvent ev) {
runningTasks.add( ev.getProcess() );
- @SuppressWarnings("unchecked")
- Iterator<ExecutionListener> iter = ((HashSet<ExecutionListener>) executionListeners.clone()).iterator();
- while (iter.hasNext()) {
- ExecutionListener l = iter.next();
- l.startedExecution(ev);
+ synchronized (executionListeners) {
+ Iterator<ExecutionListener> iter = executionListeners.iterator();
+ while (iter.hasNext()) {
+ ExecutionListener l = iter.next();
+ l.startedExecution(ev);
+ }
}
}
/** fires event that notifies about the end of a process */
protected final void fireExecutionFinished (ExecutionEvent ev) {
runningTasks.remove( ev.getProcess() );
- @SuppressWarnings("unchecked")
- Iterator<ExecutionListener> iter = ((HashSet<ExecutionListener>) executionListeners.clone()).iterator();
- while (iter.hasNext()) {
- ExecutionListener l = iter.next();
- l.finishedExecution(ev);
+ synchronized (executionListeners) {
+ Iterator<ExecutionListener> 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) {
@@ -296,5 +298,4 @@ public final class
static PrintStream createPrintStream(boolean stdOut) {
return new WriterPrintStream(new SysOut(stdOut), stdOut);
}
-
}
diff --git a/platform/openide.util/src/org/openide/util/RequestProcessor.java b/platform/openide.util/src/org/openide/util/RequestProcessor.java
index eb91719c57b..d1f8e2ee400 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 @@ outer: do {
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.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists