Skip to content
Permalink
Browse files
Mkae easier to set daemon status
  • Loading branch information
AlanBateman committed Feb 27, 2021
1 parent 4563be0 commit 10922056f742a9266209d2c7939408290064559d
Showing 1 changed file with 14 additions and 2 deletions.
@@ -696,13 +696,13 @@ public interface VirtualThreadTask extends Runnable {
* // Starts a daemon thread with name "duke"
* Thread thread = Thread.builder()
* .name("duke")
* .daemon(true)
* .daemon()
* .priority(Thread.NORM_PRIORITY)
* .task(runnable)
* .start();
*
* // A ThreadFactory that creates daemon threads named "worker-0", "worker-1", ...
* ThreadFactory factory = Thread.builder().daemon(true).name("worker-", 0).factory();
* ThreadFactory factory = Thread.builder().daemon().name("worker-", 0).factory();
*
* // Start an unnamed virtual thread
* Thread thread = Thread.builder().virtual().task(runnable).start();
@@ -876,6 +876,18 @@ default Thread start() {
*/
Builder daemon(boolean on);

/**
* Sets the daemon status to {@code true}.
* The {@link #isDaemon() daemon status} of virtual threads is always {@code true}.
* Setting the daemon status of a virtual thread has no effect.??
* @implSpec The default implementation invokes {@linkplain #daemon(boolean)} with
* a value of {@code true}.
* @return this builder
*/
default Builder daemon() {
return daemon(true);
}

/**
* Sets the thread priority.
* The priority of virtual threads is always {@linkplain Thread#NORM_PRIORITY}.

0 comments on commit 1092205

Please sign in to comment.