syntaxpublic class runtime extends object
example 的中文翻译为:示例public class runtimetest { static class message extends thread { public void run() { system.out.println(" exit"); } } public static void main(string[] args) { try { runtime.getruntime().addshutdownhook(new message()); system.out.println(" program started..."); system.out.println(" wait for 5 seconds..."); thread.sleep(5000); system.out.println(" program ended..."); } catch(exception e) { e.printstacktrace(); } }}
输出program started...wait for 5 seconds...program ended...exit
以上就是runtime类在java中的重要性是什么?的详细内容。