|
|
@ -46,6 +46,7 @@ import java.util.concurrent.ThreadFactory; |
|
|
|
public class NamedThreadFactory implements ThreadFactory |
|
|
|
public class NamedThreadFactory implements ThreadFactory |
|
|
|
{ |
|
|
|
{ |
|
|
|
private String name; |
|
|
|
private String name; |
|
|
|
|
|
|
|
private boolean daemon; |
|
|
|
private ThreadFactory delegate; |
|
|
|
private ThreadFactory delegate; |
|
|
|
|
|
|
|
|
|
|
|
public NamedThreadFactory( String name ) |
|
|
|
public NamedThreadFactory( String name ) |
|
|
@ -53,9 +54,20 @@ public class NamedThreadFactory implements ThreadFactory |
|
|
|
this( name, Executors.defaultThreadFactory() ); |
|
|
|
this( name, Executors.defaultThreadFactory() ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public NamedThreadFactory( String name, boolean daemon ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this( name, daemon, Executors.defaultThreadFactory() ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public NamedThreadFactory( String name, ThreadFactory delegate ) |
|
|
|
public NamedThreadFactory( String name, ThreadFactory delegate ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this( name, false, delegate ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public NamedThreadFactory( String name, boolean daemon, ThreadFactory delegate ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
|
|
|
|
|
this.daemon = daemon; |
|
|
|
this.delegate = delegate; |
|
|
|
this.delegate = delegate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -64,6 +76,7 @@ public class NamedThreadFactory implements ThreadFactory |
|
|
|
Thread result = delegate.newThread(r); |
|
|
|
Thread result = delegate.newThread(r); |
|
|
|
String s = result.getName(); |
|
|
|
String s = result.getName(); |
|
|
|
result.setName( name + "[" + s + "]" ); |
|
|
|
result.setName( name + "[" + s + "]" ); |
|
|
|
|
|
|
|
result.setDaemon(daemon); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|