-
Notifications
You must be signed in to change notification settings - Fork 0
TimeOut
TimeOut
is a class designed to provide a simple mechanism for setting a timeout duration, launching a timer, and triggering a task when the timeout expires.
The TimeOut
class is used to create a timer that can execute a predefined task when the specified timeout duration is reached. It is a part of the AndroSpecter framework.
Constructs a new TimeOut
object with a specified timeout duration. If zero, the timeout duration defaults to 60 seconds.
Launches the timer with the specified timeout duration.
Cancels the currently running timer, if any.
Gets the timeout duration of this TimeOut
object.
TimeOut timeOut = new TimeOut(30); // 30 seconds timeout
timeOut.launch();
TimeOut timeOut = new TimeOut(0); // Defaults to 60 seconds
timeOut.launch();
// Some code or task here
timeOut.cancel(); // Cancels the timer before the timeout is reached
TimeOut timeOut = new TimeOut(45);
int timeoutDuration = timeOut.getTimeout();
System.out.println("Timeout Duration: " + timeoutDuration + " seconds"); // Outputs: 45 seconds
These examples demonstrate how to use the TimeOut
class to create and control a timer, either with a custom timeout duration or a default value. It offers an easy way to integrate time-sensitive operations within applications.