18,开发时线程的使用

两种方式

1.Thread

2.Runnable

package songyan;
public class test
{
    public static void main(String[] args)
    {
        new Thread()
        {
            public void run()
            {
                for(int i=0;i<1000;i++)
                {
                    System.out.println("********************1");
                }
            }
        }.start();
        
        for(int i=0;i<1000;i++)
        {
            System.out.println("**********2");
        }
        
        
        Runnable run= new Runnable()
        {
            public void run()
            {
                for(int i=0;i<1000;i++)
                {
                    System.out.println("**3");
                }
            }
        };
        Thread t= new Thread(run);
        t.start();
    }
}
原文地址:https://www.cnblogs.com/exexex/p/8435432.html