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

📄 ex_18.java

📁 JAVA分布式程序学习的课件(全英文)
💻 JAVA
字号:
// program to illustrate the use of threads
// based on Deitel text ex. 13.3

import java.io.*;
import java.util.*;

public class Ex_18  
{
	
	public static void main(String[] args)
	{
	   PrintThread thread1, thread2, thread3;	
           System.out.println("This is the main thread.\n");
           thread1 = new PrintThread ( "1");
           thread2 = new PrintThread ( "2");
           thread3 = new PrintThread ( "3");

           thread1.start();
           thread2.start();
           thread3.start();
	}
} // end class Ex_18

class PrintThread extends Thread{  

        // thread constructor

        public PrintThread ( String id )
        {
             super( id );
             System.out.println ("Thread " + id + "created\n");
        }

	public void run() // thread execution
	{
           System.out.println("Thread " + getName( ) + " here\n");
	}

} // end class PrintThread

⌨️ 快捷键说明

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