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

📄 threethread.java

📁 递归子程序法:对应每个非终结符语法单元编一个独立的处理过程(或子程序)。语法分析从读入第一个单词开始
💻 JAVA
字号:
	package threethread;
	/** 
	 * Java语言实验参考程序
	 * Company 北京师范大学计算机系 
	 * @author 孙一林
	 * @version 1.0
	 */
		public class ThreeThread implements Runnable {			// 实现Runnable接口
			ThreeThread() {									// 构造方法
				Thread Thread1 = Thread.currentThread();	// 定义线程1
				Thread1.setName( "The first main thread" );	// 设置线程名
				System.out.println( "The running thread:" + Thread1 );
				Thread Thread2 = new Thread( this,"the second thread" );
				System.out.println( "creat second thread" );
				Thread2.start();							// 启动线程2
				Thread Thread3 = new Thread( this,"the third thread" );
				System.out.println( "creat third thread" );
				Thread3.start();							// 启动线程3
			}
			public void run() {								// 重构run方法
				try {
 					for ( int i = 0; i < 5; i++ ) {
						System.out.println( "Sleep time for thread :" + i );
						Thread.sleep( 1000 );				// 线程休眠
					}
				}
				catch ( InterruptedException e ) {
					System.out.println( "thread has wrong" );
				} 
			}
			public static void main(String args[]) {
				new ThreeThread();					// 创建3个线程对象
			}
		} 

⌨️ 快捷键说明

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