Create VitroBackroundThread.getLivingThreads() method.
This commit is contained in:
parent
cbc53bd701
commit
e6a34bf0a7
1 changed files with 16 additions and 0 deletions
|
@ -23,6 +23,9 @@ public class VitroBackgroundThread extends Thread {
|
||||||
|
|
||||||
private static final ConcurrentLinkedQueue<WeakReference<VitroBackgroundThread>> allThreads = new ConcurrentLinkedQueue<WeakReference<VitroBackgroundThread>>();
|
private static final ConcurrentLinkedQueue<WeakReference<VitroBackgroundThread>> allThreads = new ConcurrentLinkedQueue<WeakReference<VitroBackgroundThread>>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all VitroBackgroundThreads that have not been garbage-collected.
|
||||||
|
*/
|
||||||
public static List<VitroBackgroundThread> getThreads() {
|
public static List<VitroBackgroundThread> getThreads() {
|
||||||
List<VitroBackgroundThread> list = new ArrayList<VitroBackgroundThread>();
|
List<VitroBackgroundThread> list = new ArrayList<VitroBackgroundThread>();
|
||||||
for (WeakReference<VitroBackgroundThread> ref : allThreads) {
|
for (WeakReference<VitroBackgroundThread> ref : allThreads) {
|
||||||
|
@ -34,6 +37,19 @@ public class VitroBackgroundThread extends Thread {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all VitroBackgroundThreads that have not died.
|
||||||
|
*/
|
||||||
|
public static List<VitroBackgroundThread> getLivingThreads() {
|
||||||
|
List<VitroBackgroundThread> list = new ArrayList<VitroBackgroundThread>();
|
||||||
|
for (VitroBackgroundThread t : getThreads()) {
|
||||||
|
if (t.isAlive()) {
|
||||||
|
list.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public enum WorkLevel {
|
public enum WorkLevel {
|
||||||
IDLE, WORKING
|
IDLE, WORKING
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue