zoukankan      html  css  js  c++  java
  • setDaemon的简单使用

    //copyright©liupengcheng
    //http://www.cnblogs.com/liupengcheng

    /**
    * Created by Administrator on 2014/10/23.
    *
    *
    setDaemon
    public final void setDaemon(boolean on)将该线程标记为守护线程或用户线程。当正在运行的线程都是守护线程时,Java 虚拟机退出。
    该方法必须在启动线程前调用。

    该方法首先调用该线程的 checkAccess 方法,且不带任何参数。这可能抛出 SecurityException(在当前线程中)。

    参数:
    on - 如果为 true,则将该线程标记为守护线程。
    */

    //copyright©liupengcheng
    //http://www.cnblogs.com/liupengcheng

    public class ThreadDemo3 {
        public static void main(String [] args){
            TestThread1 tt = new TestThread1();
            Thread t = new Thread(tt);
            t.setDaemon(true);
            t.start();
        }
    }

    //copyright©liupengcheng
    //http://www.cnblogs.com/liupengcheng


    class TestThread1 implements Runnable{
        public void run()
        {
            while (true)
            {
                System.out.println(Thread.currentThread().getName()+"is running");
            }
        }

    }

    //copyright©liupengcheng
    //http://www.cnblogs.com/liupengcheng

    //输出结果为空,因为所有线程都为守护线程,Java 虚拟机退出

  • 相关阅读:
    ffmpeg文档22-混合器(复用器)
    ffmpeg文档21-分离器
    ffmpeg文档20-格式选项
    ffmpeg文档19-比特流滤镜
    ffmpeg文档18-字幕编码器
    ffmpeg文档17-视频编码器
    ffmpeg文档16-音频编码器
    python 学习笔记,selenium 自动化测试 更新开始
    python 遇到 'unicode' object is not callable 错误
    字符串函数汇总
  • 原文地址:https://www.cnblogs.com/liupengcheng/p/4045886.html
Copyright © 2011-2022 走看看