use of java.util.Timer in project Openfire by igniterealtime.
the class MediaProxySession method addKeepAlive.
/**
* Add a keep alive detector.
* If the packet still more than the keep alive delay without receiving any packets. The Session is
* stoped and remove from agents List.
*
* @param delay delay time in millis to check if the channel is inactive
*/
void addKeepAlive(long delay) {
if (idleTimer != null)
return;
idleTimer = new Timer();
idleTimer.scheduleAtFixedRate(new TimerTask() {
long lastTimeStamp = getTimestamp();
@Override
public void run() {
if (lastTimeStamp == getTimestamp()) {
stopAgent();
return;
}
lastTimeStamp = getTimestamp();
}
}, delay, delay);
}
use of java.util.Timer in project Openfire by igniterealtime.
the class MediaProxySession method addLifeTime.
/**
* Add a limited life time to the Session.
* The Session is stoped and remove from agents List after a certain time.
* Prevents that network cycles, refreshes a Session forever.
*
* @param lifetime time in Seconds to kill the Session
*/
void addLifeTime(long lifetime) {
lifetime *= 1000;
if (lifeTimer != null)
return;
lifeTimer = new Timer();
lifeTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
stopAgent();
}
}, lifetime, lifetime);
}
use of java.util.Timer in project jfinal by jfinal.
the class TimeSize method start.
public void start() {
if (!running) {
timer = new Timer("JFinal-Scanner", true);
task = new TimerTask() {
public void run() {
working();
}
};
timer.schedule(task, 1010L * interval, 1010L * interval);
running = true;
}
}
use of java.util.Timer in project FastDev4Android by jiangqqlmj.
the class AutoGallery method start.
/**
* 开启定时器
*/
public void start() {
if (length > 0 && timer == null) {
timer = new Timer();
//进行每个delayMillis时间gallery切换一张图片
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (length > 0) {
onKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT, null);
}
}
}, delayMillis, delayMillis);
}
}
use of java.util.Timer in project enumerable by hraberg.
the class LambdaTest method createSingleAbstractMethodWithLibrarySuperClass.
@Test
public void createSingleAbstractMethodWithLibrarySuperClass() throws Exception {
Timer timer = new Timer();
int x = 0;
TimerTask t = delegate(x = 1);
timer.schedule(t, 50);
assertEquals(0, x);
sleep(100);
assertEquals(1, x);
}
Aggregations