- Java.util - WeakHashMap
- Java.util - Vector
- Java.util - UUID
- Java.util - TreeSet
- Java.util - TreeMap
- Java.util - TimeZone
- Java.util - TimerTask
- Java.util - Timer
- Java.util - StringTokenizer
- Java.util - Stack
- Java.util - SimpleTimeZone
- Java.util - ServiceLoader
- Java.util - Scanner
- Java.util - ResourceBundle.Control
- Java.util - ResourceBundle
- Java.util - Random
- Java.util - PropertyResourceBundle
- Java.util - PropertyPermission
- Java.util - Properties
- Java.util - PriorityQueue
- Java.util - Observable
- Java.util - Locale
- Java.util - ListResourceBundle
- Java.util - LinkedList
- Java.util - LinkedHashSet
- Java.util - LinkedHashMap
- Java.util - IdentityHashMap
- Java.util - Hashtable
- Java.util - HashSet
- Java.util - HashMap
- Java.util - GregorianCalendar
- Java.util - Formatter
- Java.util - EnumSet
- Java.util - EnumMap
- Java.util - Dictionary
- Java.util - Date
- Java.util - Currency
- Java.util - Collections
- Java.util - Calendar
- Java.util - BitSet
- Java.util - Arrays
- Java.util - ArrayList
- Java.util - ArrayDeque
- Java.util - Home
Java.util Package Extras
- Java.util - Discussion
- Java.util - Useful Resources
- Java.util - Enumerations
- Java.util - Exceptions
- Java.util - Interfaces
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.util.Timer Class
Introduction
The java.util.Timer class provides facipty for threads to schedule tasks for future execution in a background thread.
This class is thread-safe i.e multiple threads can share a single Timer object without the need for external synchronization.
This class schedules tasks for one-time execution, or for repeated execution at regular intervals.
All constructors start a timer thread.
Class declaration
Following is the declaration for java.util.Timer class −
pubpc class Timer extends Object
Class constructors
Sr.No. | Constructor & Description |
---|---|
1 | Timer() This constructor creates a new timer. |
2 | Timer(boolean isDaemon) This constructor creates a new timer whose associated thread may be specified to run as a daemon. |
3 | Timer(String name) This constructor creates a new timer whose associated thread has the specified name. |
4 | Timer(String name, boolean isDaemon) This constructor creates a new timer whose associated thread has the specified name, and may be specified to run as a daemon. |
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method terminates this timer, discarding any currently scheduled tasks. |
2 | This method removes all cancelled tasks from this timer s task queue. |
3 | This method schedules the specified task for execution at the specified time. |
4 | This method schedules the specified task for repeated fixed-delay execution, beginning at the specified time. |
5 | This method schedules the specified task for execution after the specified delay. |
6 | This method schedules the specified task for repeated fixed-delay execution, beginning after the specified delay. |
7 | This method schedules the specified task for repeated fixed-rate execution, beginning at the specified time. |
8 | This method Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay. |
Methods inherited
This class inherits methods from the following classes −
java.util.Object