summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libart/src/main/java/java/lang/Daemons.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/libart/src/main/java/java/lang/Daemons.java b/libart/src/main/java/java/lang/Daemons.java
index 76f4ea9..72ba387 100644
--- a/libart/src/main/java/java/lang/Daemons.java
+++ b/libart/src/main/java/java/lang/Daemons.java
@@ -57,12 +57,21 @@ public final class Daemons {
*/
private static abstract class Daemon implements Runnable {
private Thread thread;
+ private String name;
+
+ public Daemon(String name) {
+ this.name = name;
+ }
+
+ public Daemon() {
+ this.name = getClass().getSimpleName();
+ }
public synchronized void start() {
if (thread != null) {
throw new IllegalStateException("already running");
}
- thread = new Thread(ThreadGroup.systemThreadGroup, this, getClass().getSimpleName());
+ thread = new Thread(ThreadGroup.systemThreadGroup, this, name);
thread.setDaemon(true);
thread.start();
}
@@ -127,6 +136,10 @@ public final class Daemons {
private static class ReferenceQueueDaemon extends Daemon {
private static final ReferenceQueueDaemon INSTANCE = new ReferenceQueueDaemon();
+ ReferenceQueueDaemon() {
+ super("ReferenceQueueDaemon");
+ }
+
@Override public void run() {
while (isRunning()) {
Reference<?> list;
@@ -163,6 +176,10 @@ public final class Daemons {
private volatile Object finalizingObject;
private volatile long finalizingStartedNanos;
+ FinalizerDaemon() {
+ super("FinalizerDaemon");
+ }
+
@Override public void run() {
while (isRunning()) {
// Take a reference, blocking until one is ready or the thread should stop
@@ -203,6 +220,10 @@ public final class Daemons {
private static class FinalizerWatchdogDaemon extends Daemon {
private static final FinalizerWatchdogDaemon INSTANCE = new FinalizerWatchdogDaemon();
+ FinalizerWatchdogDaemon() {
+ super("FinalizerWatchdogDaemon");
+ }
+
@Override public void run() {
while (isRunning()) {
boolean waitSuccessful = waitForObject();
@@ -305,6 +326,10 @@ public final class Daemons {
private static class HeapTaskDaemon extends Daemon {
private static final HeapTaskDaemon INSTANCE = new HeapTaskDaemon();
+ HeapTaskDaemon() {
+ super("HeapTaskDaemon");
+ }
+
// Overrides the Daemon.interupt method which is called from Daemons.stop.
public synchronized void interrupt(Thread thread) {
VMRuntime.getRuntime().stopHeapTaskProcessor();