⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threadtest1.java

📁 里面包含了很多的JAVA基础的源程序,算法,想看就下吧
💻 JAVA
字号:
package untitled1;

public class ThreadTest1
{
    public static void main(String[] args)
    {
        test1 t = new test1();
        Thread th1 = new Thread(t);
        Thread th2 = new Thread(t);
        Thread th3 = new Thread(t);
        Thread th4 = new Thread(t);

        th1.start();
        th2.start();
        th3.start();
        th4.start();

        new Thread(t).start();
        new Thread(t).start();

    }
}

class test1 implements Runnable
{
    int count = 50;
    public void run() {
        for(;;)
        {
            if(count>0)
            {
                try {
                    Thread.sleep(30);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+"  "+count--);
            }
            else
                break;
        }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -