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

📄 processclasslocktest.java

📁 kaffe Java 解释器语言,源码,Java的子集系统,开放源代码
💻 JAVA
字号:
/** * a test to ensure we do upcalls to static initializers properly. * * @author Godmar Back <gback@cs.utah.edu> */class Base {    static {	try {	    Thread.sleep(5000);	} catch (Exception e) {	    System.out.println(e);	}    }}class Sub extends Base {}public class ProcessClassLockTest{    public static void main(String av[]) throws Exception {	// a watchdog thread that kills us off after 2.5 sec	new Thread() {	    public void run() {		try {		    Thread.sleep(2500);		    System.out.println("sorry, you timed out");		    System.exit(-1);		} catch (Exception e) {		    System.out.println(e);		}	    }	}.start();	// a thread that will load Sub and Base	new Thread() {	    public void run() {		try {		    Class.forName("Sub");		} catch (Throwable t) {		    System.out.println(t);		}	    }	}.start();	// get thread 2 going	Thread.sleep(1000);	/* this thread should be unaffected by the fact that thread 2	 * sleeps in the static initializer of Base	 */	Thread th;	th = new Thread() {	    public void run() {		try {		    Class.forName("this_class_does_not_exist");		} catch (Throwable t) {		    System.out.println(t);		}		System.exit(0);	    }	};	th.start();	try	{	    th.join();	}	catch (InterruptedException ie)	{	    System.out.println("interrupted");	}    }}/* Expected Output:java.lang.ClassNotFoundException: this_class_does_not_exist*/

⌨️ 快捷键说明

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