zoukankan      html  css  js  c++  java
  • Java多线程实现......(1,继承Thread类)

    MyThread.java 中的代码:
    public class MyThread extends Thread{
        private int startPrint,printCount;
        private String threadName;
    
        public MyThread(int startPrint ,int printCount ,String threadName){
            this.startPrint = startPrint;
            this.printCount = printCount;
            this.threadName = threadName;
        }
        public void run(){
            for(int i=0 ;i<printCount ;i++){
                System.out.println(threadName + ":" + (i + startPrint));    
            }
        }
    }
    
    MainThread:
    public class MainThread{
        public static void main(String[] args){
            MyThread mt1 = new MyThread(1   ,100 ,"Thread 1 ");
            MyThread mt2 = new MyThread(100 ,120 ,"Thread 2 ");
    
            mt1.start();
            mt2.start();
        }
    }
    
  • 相关阅读:
    生成密码
    生成密码
    C#委托
    C#委托
    C#委托
    最近所有博客
    win10 uwp 读写XML
    win10 uwp 读写XML
    win10 uwp 读写XML
    win10 uwp 绑定密码
  • 原文地址:https://www.cnblogs.com/joneblogs/p/3355993.html
Copyright © 2011-2022 走看看