com.bixuebihui.util.JavaAlarm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of c-dbtools Show documentation
Show all versions of c-dbtools Show documentation
a fast small database connection pool and a active record flavor mini framework
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov Date: 2005-1-4 11:29:44
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: JavaAlarm.java
package com.bixuebihui.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* JavaAlarm class.
*
* @author xingwx
* @version $Id: $Id
*/
public final class JavaAlarm extends Thread
{
private static final Logger LOG = LoggerFactory.getLogger(JavaAlarm.class);
/**
* {@inheritDoc}
*/
@Override
public void run() {
completed = false;
r.run();
synchronized(this) {
completed = true;
notifyAll();
}
}
/**
* Constructor for JavaAlarm.
*
* @param runnable a {@link java.lang.Runnable} object.
* @param maxWait a long.
* @throws TimeoutException if any.
*/
public JavaAlarm(Runnable runnable, long maxWait)
throws TimeoutException{
r = runnable;
completed = false;
long step =maxWait/10+1;
long count = step;
synchronized(this) {
start();
while (!completed) {
try {
wait(step);
if(!completed && count