-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStop_processing.java
53 lines (48 loc) · 1.5 KB
/
Stop_processing.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package QuickPALM;
import ij.IJ;
import ij.gui.GenericDialog;
import ij.plugin.PlugIn;
/** This plugin halts the Analyse Particles threads. */
public class Stop_processing implements PlugIn {
public void run(String arg) {
ThreadGroup group = Thread.currentThread().getThreadGroup();
int activeCount = group.activeCount();
Thread[] threads = new Thread[activeCount];
group.enumerate(threads);
int j = 0;
for (int i = 0; i < activeCount; i++) {
String name = threads[i].getName();
if (threads[i] == Thread.currentThread() ||
name.startsWith("AWT-") ||
name.equals("Java2D Disposer") ||
name.equals("SocketListener") ||
name.equals("DestroyJavaVM") ||
name.equals("TimerQueue"))
continue;
if (j < i)
threads[j] = threads[i];
System.err.println("nr " + i + ": " + threads[i].getName());
j++;
}
activeCount = j;
if (activeCount == 0) {
IJ.showMessage("No threads to kill.");
return;
}
String[] names = new String[activeCount];
int foundThread=-1;
//for (int i = 0; i < activeCount; i++)
// names[i] = threads[i].getName();
for (int i = 0; i < activeCount; i++)
if (threads[i].getName().equals("Run$_Analyse Particles"))
foundThread=i;
//GenericDialog gd = new GenericDialog("Thread Killer");
//gd.addChoice("Thread:", names, names[0]);
//gd.showDialog();
//if (gd.wasCanceled())
// return;
//int threadIndex = gd.getNextChoiceIndex();
//threads[threadIndex].stop();
if (foundThread!=-1) threads[foundThread].stop();
}
}