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

📄 methodtest.java

📁 讲解在java平台上用AWT编写与图形有关的小程序
💻 JAVA
字号:
public class MethodTest {
	public static void main(String[] args) {
		FirstThread first = new FirstThread();
		SecondThread second = new SecondThread();
		first.start();
		second.start();
		try {
			System.out.println("Waiting for first thread to finish...");
			first.join();
			System.out.println("It's a long wait!");
			System.out.println("Waking up second thread..");
			second.resume();
			System.out.println("Waiting for second thread to finish..");
			second.join();
		} catch (InterruptedException e) {
		}
		System.out.println("I'm ready to finish too.");
	}
}

class FirstThread extends Thread {
	public void run() {
		try {
			System.out.println("First thread starts running.");
			sleep(10000);
			System.out.println("First thread finishes running.");
		} catch (InterruptedException e) {
		}
	}
}
	
class SecondThread extends Thread {
	public void run() {
		System.out.println("Second thread starts running.");
		System.out.println("Second thread suspend itself.");
		suspend();
		System.out.println("Second thread runs again and finishes.");
	}
}
	

⌨️ 快捷键说明

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