thread1.java

来自「a simple thread program to print numbers」· Java 代码 · 共 66 行

JAVA
66
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package ashish;public class Thread1  {     Thread t1=new Thread();    Thread t2= new Thread();    int count=0;        //    public static void main(String arg[]){//        isEmpty();//    }public void isEmpty1()    {    t1.start(); //starts the thread}    public void isEmpty()    {        try         {            t1.suspend(); //suspends the thread            Add();        }        catch(Exception ex)        {            ex.printStackTrace();        }    }    public void Add()    {        try        {             if(count==5)            {                                System.exit(0);            }            count++;            System.out.println(count);            t1.resume();            isEmpty();                    }        catch (Exception ex)        {            ex.printStackTrace();        }    }    public void run()    {           }    }

⌨️ 快捷键说明

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