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

📄 preempt.java

📁 kaffe Java 解释器语言,源码,Java的子集系统,开放源代码
💻 JAVA
字号:
public class Preempt implements Runnable{    public final static int TIMEOUT = 2000;    public static void main(String args[])    {	new Thread() {	    public void run() {		try {		    Thread.sleep(TIMEOUT);		} catch (InterruptedException _) {		    ;		}		System.exit(0);	    }	}.start();	for (int i = 0; i < 5; i++)	    new Thread(new Preempt(), "thread " + i).start();	synchronized(Preempt.class) {	    System.out.println("started 5 threads");	}    }    public void run()    {	// this shouldn't be necessary---System.out.println should be	// synchronized, but it apparently is (9/30/99)	synchronized(Preempt.class) {	    System.out.println(Thread.currentThread().getName());	}	while (true) {		continue;	}    }}// Sort output/* Expected Output:started 5 threadsthread 0thread 1thread 2thread 3thread 4*/

⌨️ 快捷键说明

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