📄 javaalarm.java
字号:
package org.ehotsoft.yekki.sql.pool;public class JavaAlarm extends Thread { Runnable r; boolean completed; public JavaAlarm( Runnable r, long timeout ) throws TimeoutException { super(); this.r = r; this.completed = false; start(); synchronized( this ) { try { if( !completed ) wait( timeout ); } catch( InterruptedException e ) { e.printStackTrace(); } } if( !completed ) { stop(); throw new TimeoutException( "Runnable did not complete within " + timeout + "ms" ); } } public void run() { completed = false; r.run(); completed = true; synchronized(this) { notifyAll(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -