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

📄 newthread.java

📁 java 数据结构的一些简单实例和一些线程的应用主要是面向初学者
💻 JAVA
字号:

class NewThread extends Thread 
{
    NewThread()
    {
    	super("Demo1 Thread");
    	System.out.println("Child thread:"+this);
    	start();
    }
    
    public void run()
    {
    	try
    	{
    		for(int i=20;i>0;i--)
    			System.out.println("Child Thread :"+i);
    		Thread.sleep(5000);
    		
    	}catch(InterruptedException e)
    	{
    		System.out.println("Exiting child thread.");
    	}
    	System.out.println("Exiting child thread");
    }
    
}

class ExtendThread
{
	public static void main(String args[])
	{
		new NewThread();
		try
		{
			for(int i=15;i>0;i--)
			{
				System.out.println("Main Thread :"+i);
				Thread.sleep(1000);
			}
		}catch(InterruptedException e)
		{
			System.out.println("Main thread interrrupted.");
		}
		System.out.println("Main thread exting.");
	}
}

⌨️ 快捷键说明

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