zoukankan      html  css  js  c++  java
  • 多线程

    package 增删改查;
    public class SimpleThread extends Thread {
        public SimpleThread(String name) {        // 参数为线程名称
            setName(name);
        }
        public void run() {        // 覆盖run()方法
            int i = 0;
            while (i++ < 5) {         // 循环5次
                try {
                    System.out.println(getName() + "执行步骤" + i);
                    Thread.sleep(1000);     // 休眠1秒
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        public static void main(String[] args) {
            SimpleThread thread1 = new SimpleThread("线程1");     // 创建线程1
            SimpleThread thread2 = new SimpleThread("线程2");     // 创建线程2
            thread1.start();                                     // 启动线程1
            thread2.start();                                    // 启动线程2
        }
    }
    

      

  • 相关阅读:
    模块
    匿名函数
    推导式
    函数 重点
    新的
    知识点补充
    unity学习规划与进度
    暂停·笔记
    解决问题__max 模型白色 材质球换没用
    Max__cs骨骼
  • 原文地址:https://www.cnblogs.com/da48/p/14229091.html
Copyright © 2011-2022 走看看