List of usage examples for java.util TimerTask scheduledExecutionTime
public long scheduledExecutionTime()
From source file:MyTimerTask.java
public static void main(String[] args) { // creating timer task, timer TimerTask task = new MyTimerTask(); Timer timer = new Timer(); // scheduling the task timer.scheduleAtFixedRate(task, new Date(), 1000); // checking scheduled execution time System.out.println("Time is :" + task.scheduledExecutionTime()); }
From source file:org.opcfoundation.ua.transport.https.HttpsClient.java
/** * Sets new Timer Task that timeouts pending requests. * If task already exists but is too far in the future, it is canceled and new task assigned */// w w w.j a va 2 s. c o m private void scheduleTimeoutRequestsTimer() { HttpsClientPendingRequest nextRequest = _getNextTimeoutingPendingRequest(); // Cancel task if (nextRequest == null) { cancelTimeoutPendingRequestTask(); } else { TimerTask task = timeoutPendingRequestsTask.get(); // Task does not exists or is not ok if (task == null || task.scheduledExecutionTime() > nextRequest.timeoutTime) { cancelTimeoutPendingRequestTask(); // Create a new task task = TimerUtil.schedule(timer, timeoutRun, executor, nextRequest.timeoutTime); if (!timeoutPendingRequestsTask.compareAndSet(null, task)) // it was already set task.cancel(); } } }