public class TimeoutService extends Object
Implemented having large scale programs in mind: if you open many concurrent SSH connections that rely on timeouts, then there will be only one timeout thread. Once all timeouts have expired/are cancelled, the thread will (sooner or later) exit. Only after new timeouts arrive a new thread (singleton) will be instantiated.
Modifier and Type | Class and Description |
---|---|
static class |
TimeoutService.TimeoutToken |
Constructor and Description |
---|
TimeoutService() |
Modifier and Type | Method and Description |
---|---|
static TimeoutService.TimeoutToken |
addTimeoutHandler(long runTime,
Runnable handler)
It is assumed that the passed handler will not execute for a long time.
|
static void |
cancelTimeoutHandler(TimeoutService.TimeoutToken token)
Cancel the timeout callback for the specified token.
|
public static final TimeoutService.TimeoutToken addTimeoutHandler(long runTime, Runnable handler)
runTime
- runTimehandler
- handlerpublic static final void cancelTimeoutHandler(TimeoutService.TimeoutToken token)
token
- token to be canceled.Copyright © 2020. All rights reserved.