Skip to content

Commit cbe97ae

Browse files
committed
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.
1 parent 720775f commit cbe97ae

File tree

3 files changed

+8
-48
lines changed

3 files changed

+8
-48
lines changed

platform/core.execution/src/org/netbeans/core/execution/DefaultSysProcess.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -101,35 +101,4 @@ public void run() {
101101
public String getName() {
102102
return name;
103103
}
104-
105-
/** destroy the thread group this process was handled from. Not that simple
106-
* as it seems, since the ThreadGroup can't be destroyed from inside.
107-
*/
108-
void destroyThreadGroup(ThreadGroup base) {
109-
new Thread(base, new Destroyer(group)).start();
110-
}
111-
private static class Destroyer implements Runnable {
112-
private final ThreadGroup group;
113-
Destroyer(ThreadGroup group) {
114-
this.group = group;
115-
}
116-
@Override public void run() {
117-
try {
118-
while (group.activeCount() > 0) {
119-
Thread.sleep(1000);
120-
}
121-
}
122-
catch (InterruptedException e) {
123-
Exceptions.printStackTrace(e);
124-
}
125-
if (!group.isDestroyed()) {
126-
try {
127-
group.destroy();
128-
} catch (IllegalThreadStateException x) {
129-
// #165302: destroyed some other way?
130-
}
131-
}
132-
}
133-
}
134-
135104
}

platform/core.execution/src/org/netbeans/core/execution/ExecutionEngine.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@
7171

7272
/* table of window:threadgrp */
7373
private static final WindowTable wtable = new WindowTable();
74-
74+
7575
/** list of ExecutionListeners */
76-
private final HashSet<ExecutionListener> executionListeners = new HashSet<>();
76+
private final Set<ExecutionListener> executionListeners;
7777

7878
/** List of running executions */
7979
private final List<ExecutorTask> runningTasks = Collections.synchronizedList(new ArrayList<>(5));
@@ -87,6 +87,8 @@
8787
static final long serialVersionUID =9072488605180080803L;
8888

8989
public ExecutionEngine () {
90+
this.executionListeners = new HashSet<>();
91+
9092
/* SysIn is a class that redirects System.in of some running task to
9193
a window (probably OutWindow).
9294
SysOut/Err are classes that redirect out/err to the window
@@ -134,7 +136,6 @@ public String getRunningTaskName( ExecutorTask task ) {
134136
@Override
135137
public ExecutorTask execute(String name, Runnable run, final InputOutput inout) {
136138
TaskThreadGroup g = new TaskThreadGroup(base, "exec_" + name + "_" + number); // NOI18N
137-
g.setDaemon(true);
138139
ExecutorTaskImpl task = new ExecutorTaskImpl();
139140
synchronized (task.lock) {
140141
try {
@@ -193,24 +194,21 @@ protected final PermissionCollection createPermissions(CodeSource cs, InputOutpu
193194
/** fires event that notifies about new process */
194195
protected final void fireExecutionStarted (ExecutionEvent ev) {
195196
runningTasks.add( ev.getProcess() );
196-
@SuppressWarnings("unchecked")
197-
Iterator<ExecutionListener> iter = ((HashSet<ExecutionListener>) executionListeners.clone()).iterator();
197+
Iterator<ExecutionListener> iter = (new HashSet<>(executionListeners)).iterator();
198198
while (iter.hasNext()) {
199199
ExecutionListener l = iter.next();
200200
l.startedExecution(ev);
201-
}
201+
}
202202
}
203203

204204
/** fires event that notifies about the end of a process */
205205
protected final void fireExecutionFinished (ExecutionEvent ev) {
206-
runningTasks.remove( ev.getProcess() );
207-
@SuppressWarnings("unchecked")
208-
Iterator<ExecutionListener> iter = ((HashSet<ExecutionListener>) executionListeners.clone()).iterator();
206+
runningTasks.remove(ev.getProcess());
207+
Iterator<ExecutionListener> iter = (new HashSet<>(executionListeners)).iterator();
209208
while (iter.hasNext()) {
210209
ExecutionListener l = iter.next();
211210
l.finishedExecution(ev);
212211
}
213-
ev.getProcess().destroyThreadGroup(base);
214212
}
215213

216214
static void putWindow(java.awt.Window w, TaskThreadGroup tg) {
@@ -296,5 +294,4 @@ public void close() throws IOException {
296294
static PrintStream createPrintStream(boolean stdOut) {
297295
return new WriterPrintStream(new SysOut(stdOut), stdOut);
298296
}
299-
300297
}

platform/openide.util/src/org/openide/util/RequestProcessor.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,20 +1892,14 @@ static Processor get() {
18921892
return proc;
18931893
}
18941894
} else {
1895-
assert checkAccess(TOP_GROUP.getTopLevelThreadGroup());
18961895
Processor proc = POOL.pop();
18971896
proc.idle = false;
1898-
18991897
return proc;
19001898
}
19011899
}
19021900
newP = new Processor();
19031901
}
19041902
}
1905-
private static boolean checkAccess(ThreadGroup g) throws SecurityException {
1906-
g.checkAccess();
1907-
return true;
1908-
}
19091903

19101904
/** A way of returning a Processor to the inactive pool.
19111905
*

0 commit comments

Comments
 (0)