本文整理了Java中java.lang.Thread.setDaemon()
方法的一些代码示例,展示了Thread.setDaemon()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Thread.setDaemon()
方法的具体详情如下:
包路径:java.lang.Thread
类名称:Thread
方法名:setDaemon
[英]Marks this thread as either a #isDaemon thread or a user thread. The Java Virtual Machine exits when the only threads running are all daemon threads.
This method must be invoked before the thread is started.
[中]将此线程标记为#isDaemon线程或用户线程。当运行的线程都是守护进程线程时,Java虚拟机将退出。
必须在线程启动之前调用此方法。
代码示例来源:origin: square/okhttp
public static ThreadFactory threadFactory(String name, boolean daemon) {
return runnable -> {
Thread result = new Thread(runnable, name);
result.setDaemon(daemon);
return result;
};
}
代码示例来源:origin: apache/incubator-dubbo
public Notifier(String service) {
super.setDaemon(true);
super.setName("DubboRedisSubscribe");
this.service = service;
}
代码示例来源:origin: apache/incubator-dubbo
public Notifier(String service) {
super.setDaemon(true);
super.setName("DubboRedisSubscribe");
this.service = service;
}
代码示例来源:origin: libgdx/libgdx
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r, "NetThread");
thread.setDaemon(true);
return thread;
}
});
代码示例来源:origin: libgdx/libgdx
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r, "NetThread");
thread.setDaemon(true);
return thread;
}
});
代码示例来源:origin: libgdx/libgdx
@Override
public Thread newThread (Runnable r) {
Thread thread = new Thread(r, "AsynchExecutor-Thread");
thread.setDaemon(true);
return thread;
}
});
代码示例来源:origin: libgdx/libgdx
@Override
public Thread newThread (Runnable r) {
Thread thread = new Thread(r, "AsynchExecutor-Thread");
thread.setDaemon(true);
return thread;
}
});
代码示例来源:origin: apache/incubator-dubbo
@Override
public Thread newThread(Runnable runnable) {
String name = mPrefix + mThreadNum.getAndIncrement();
Thread ret = new Thread(mGroup, runnable, name, 0);
ret.setDaemon(mDaemon);
return ret;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Thread newThread(Runnable runnable) {
String name = mPrefix + mThreadNum.getAndIncrement();
Thread ret = new Thread(mGroup, runnable, name, 0);
ret.setDaemon(mDaemon);
return ret;
}
代码示例来源:origin: shuzheng/zheng
@Override
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, "System Clock");
thread.setDaemon(true);
return thread;
}
});
代码示例来源:origin: jenkinsci/jenkins
public Thread newThread(Runnable r) {
Thread t = core.newThread(r);
t.setDaemon(true);
return t;
}
}
代码示例来源:origin: alibaba/druid
public Thread newThread(Runnable r) {
String threadName = nameStart + threadNo.getAndIncrement() + nameEnd;
Thread newThread = new Thread(r, threadName);
newThread.setDaemon(true);
if (newThread.getPriority() != Thread.NORM_PRIORITY) {
newThread.setPriority(Thread.NORM_PRIORITY);
}
return newThread;
}
代码示例来源:origin: google/guava
@Override
public Thread newThread(Runnable runnable) {
Thread thread = backingThreadFactory.newThread(runnable);
if (nameFormat != null) {
thread.setName(format(nameFormat, count.getAndIncrement()));
}
if (daemon != null) {
thread.setDaemon(daemon);
}
if (priority != null) {
thread.setPriority(priority);
}
if (uncaughtExceptionHandler != null) {
thread.setUncaughtExceptionHandler(uncaughtExceptionHandler);
}
return thread;
}
};
代码示例来源:origin: ctripcorp/apollo
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(threadGroup, runnable,//
threadGroup.getName() + "-" + namePrefix + "-" + threadNumber.getAndIncrement());
thread.setDaemon(daemon);
if (thread.getPriority() != Thread.NORM_PRIORITY) {
thread.setPriority(Thread.NORM_PRIORITY);
}
return thread;
}
}
代码示例来源:origin: libgdx/libgdx
public TimerThread () {
files = Gdx.files;
Gdx.app.addLifecycleListener(this);
resume();
Thread thread = new Thread(this, "Timer");
thread.setDaemon(true);
thread.start();
}
代码示例来源:origin: libgdx/libgdx
public TimerThread () {
files = Gdx.files;
Gdx.app.addLifecycleListener(this);
resume();
Thread thread = new Thread(this, "Timer");
thread.setDaemon(true);
thread.start();
}
代码示例来源:origin: google/guava
/** Returns a new started daemon Thread running the given runnable. */
Thread newStartedThread(Runnable runnable) {
Thread t = new Thread(runnable);
t.setDaemon(true);
t.start();
return t;
}
代码示例来源:origin: google/guava
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r);
thread.setName(THREAD_NAME);
thread.setPriority(THREAD_PRIORITY);
thread.setDaemon(THREAD_DAEMON);
thread.setUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER);
return thread;
}
};
代码示例来源:origin: spring-projects/spring-framework
/**
* Template method for the creation of a new {@link Thread}.
* <p>The default implementation creates a new Thread for the given
* {@link Runnable}, applying an appropriate thread name.
* @param runnable the Runnable to execute
* @see #nextThreadName()
*/
public Thread createThread(Runnable runnable) {
Thread thread = new Thread(getThreadGroup(), runnable, nextThreadName());
thread.setPriority(getThreadPriority());
thread.setDaemon(isDaemon());
return thread;
}
代码示例来源:origin: google/guava
@CanIgnoreReturnValue
static Thread startThread(Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
thread.start();
return thread;
}
内容来源于网络,如有侵权,请联系作者删除!