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>>();
|
||||
|
||||
/**
|
||||
* Get a list of all VitroBackgroundThreads that have not been garbage-collected.
|
||||
*/
|
||||
public static List<VitroBackgroundThread> getThreads() {
|
||||
List<VitroBackgroundThread> list = new ArrayList<VitroBackgroundThread>();
|
||||
for (WeakReference<VitroBackgroundThread> ref : allThreads) {
|
||||
|
@ -34,6 +37,19 @@ public class VitroBackgroundThread extends Thread {
|
|||
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 {
|
||||
IDLE, WORKING
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue