zoukankan      html  css  js  c++  java
  • 线程

    import java.util.Timer;
    import java.util.TimerTask;
    
    /**
     * Created by Administrator on 2018/3/30.
     */
    class Yield extends Thread{
        @Override
        public void run() {
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                        System.out.println("看我的眼神..>"+Thread.currentThread().getName());
                }
            },0,1000);
        }
    }
     class MyThread49 implements Runnable
    {
        public void run()
        {
            try
            {
                while (!Thread.currentThread().isInterrupted())
                {
                    System.out.println("ThreadName = " + Thread.currentThread().getName());
                    Thread.sleep(3000);
                }
            }
            catch (InterruptedException e)
            {
                e.printStackTrace();
            }
        }
    }
    public class Test {
        public static void main(String[] args) {
            Thread main = Thread.currentThread();
            ThreadGroup mainGroup = main.getThreadGroup();
            Thread thread = new Thread(mainGroup,"afengThreadGroup");
    
            Thread thread2 = new Yield();
            thread2.start();
    
            new Thread(new MyThread49()).start();
    
            new Thread(new Runnable() {
                public void run() {
                    System.out.println("强调自主练习");
                }
            }).start();
        }
    }
  • 相关阅读:
    Oracle 单引号与双引号的区别
    oracle 生成随机数
    oracle 表空间及查看所有用户的表空间
    字节和字符的区别
    java io
    Oracle 基础
    gvim 常用键
    Python之struct
    Python之MySQLdb
    Python之sqlite3
  • 原文地址:https://www.cnblogs.com/fengdaren/p/8675805.html
Copyright © 2011-2022 走看看