javaalarm.java
来自「JSP聊天系统」· Java 代码 · 共 46 行
JAVA
46 行
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 + =
减小字号Ctrl + -
显示快捷键?