SlideShare uma empresa Scribd logo
1 de 10
Baixar para ler offline
Java.util package
Timer and TimerTask class
Timer class
● The java.util.Timer class provides facility 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.
Constructors in Timer class
Constructor Description
Timer() This constructor creats a new timer
Timer(boolean isDaemon) This constructor creates a new timer
whose associated thread may be
specified to run as a daemon
Timer(String name) This constructor creates a new timer
whose associated thread has the
specified name
Timer(String name, boolean isDaemon) This constructor creates a nw timer
whose associated thread has the
specified name , and may be specified to
run as a daemon.
Methods in Timer class
Methods Description
Void cancel() This method terminates this
timer,discarding any currently scheduled
tasks.
Int purge() This method removes all cancelled tasks
from this timer's task queue
Void schedule(TimerTask task, Date time) This method schedules the specified task
for execution at the specified time
Void schedule(TiemrTask task, Date
firstTime, long period)
This method schedules the specified task
for repeated fixed-delay execution,
beginning at the specified time
Void schedule(TimerTask task, long
delay)
This method schedules the specified task
for exectuiton after the specified delay
Void schedule(TimerTask task,long delay,
long period)
This method schedules the specified task
for repeated fixed-delay execution,
beginning after the specified delay.
Cont'd
Methods Description
Void scheduleAtFixedRate(TimerTask
task,Date firstTime,long period)
This method schedules the specified task
for repeated fixed-rate exectuion,
begining at the specified time
Void scheduleAtFixedRate(TimerTask
task, long delay, long period)
This method schedules the specified task
for repeated fixed-rate execution,
beginning after the specified delay.
TimerTask class
● The java.util.TimerTask class represents a task
that can be scheduled for one-time or repeated
execution by a Timer.
protected TimerTask()-This constructor
creates a new timer task.
Methods in TimerTask class
Methods Description
Boolean cancel() This method cancels this timer task
Abstract void run() This method represents the action to be
performed by this timer task.
Long scheduledExecutionTime() This method returns the scheduled
execution time of the most recent actual
execution task
Example program using Timer and
TimerTask class
Sample program output

Mais conteúdo relacionado

Mais procurados

David cells distributed control
David cells distributed control David cells distributed control
David cells distributed control Hock Soon LOW
 
Thread priorities35
Thread priorities35Thread priorities35
Thread priorities35myrajendra
 
The discrete fourier transform (dsp) 4
The discrete fourier transform  (dsp) 4The discrete fourier transform  (dsp) 4
The discrete fourier transform (dsp) 4HIMANSHU DIWAKAR
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsRushabh2428
 
Continuous human action recognition in ambient assisted living scenarios
Continuous human action recognition in ambient assisted living scenariosContinuous human action recognition in ambient assisted living scenarios
Continuous human action recognition in ambient assisted living scenariosFrancisco (Paco) Florez-Revuelta
 
Life cycle-of-a-thread
Life cycle-of-a-threadLife cycle-of-a-thread
Life cycle-of-a-threadjavaicon
 
Fourier transforms of discrete signals (DSP) 5
Fourier transforms of discrete signals (DSP) 5Fourier transforms of discrete signals (DSP) 5
Fourier transforms of discrete signals (DSP) 5HIMANSHU DIWAKAR
 
Can recurrent neural networks warp time
Can recurrent neural networks warp timeCan recurrent neural networks warp time
Can recurrent neural networks warp timeDanbi Cho
 
parallel programming in tthe PVM-advanced system architecture
parallel programming in tthe PVM-advanced system architectureparallel programming in tthe PVM-advanced system architecture
parallel programming in tthe PVM-advanced system architectureRoslinJoseph
 
Intro to Sorting + Insertion Sort
Intro to Sorting + Insertion SortIntro to Sorting + Insertion Sort
Intro to Sorting + Insertion SortNicholas Case
 

Mais procurados (16)

David cells distributed control
David cells distributed control David cells distributed control
David cells distributed control
 
Thread priorities35
Thread priorities35Thread priorities35
Thread priorities35
 
The discrete fourier transform (dsp) 4
The discrete fourier transform  (dsp) 4The discrete fourier transform  (dsp) 4
The discrete fourier transform (dsp) 4
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and Problems
 
Continuous human action recognition in ambient assisted living scenarios
Continuous human action recognition in ambient assisted living scenariosContinuous human action recognition in ambient assisted living scenarios
Continuous human action recognition in ambient assisted living scenarios
 
Thread priorities
Thread prioritiesThread priorities
Thread priorities
 
Properties of dft
Properties of dftProperties of dft
Properties of dft
 
Java threading
Java threadingJava threading
Java threading
 
Life cycle-of-a-thread
Life cycle-of-a-threadLife cycle-of-a-thread
Life cycle-of-a-thread
 
Thread model in java
Thread model in javaThread model in java
Thread model in java
 
Fourier transforms of discrete signals (DSP) 5
Fourier transforms of discrete signals (DSP) 5Fourier transforms of discrete signals (DSP) 5
Fourier transforms of discrete signals (DSP) 5
 
(148065320) dijistra algo
(148065320) dijistra algo(148065320) dijistra algo
(148065320) dijistra algo
 
Can recurrent neural networks warp time
Can recurrent neural networks warp timeCan recurrent neural networks warp time
Can recurrent neural networks warp time
 
parallel programming in tthe PVM-advanced system architecture
parallel programming in tthe PVM-advanced system architectureparallel programming in tthe PVM-advanced system architecture
parallel programming in tthe PVM-advanced system architecture
 
Java threads
Java threadsJava threads
Java threads
 
Intro to Sorting + Insertion Sort
Intro to Sorting + Insertion SortIntro to Sorting + Insertion Sort
Intro to Sorting + Insertion Sort
 

Semelhante a Timer class in java

Session13 J2ME Timer
Session13  J2ME TimerSession13  J2ME Timer
Session13 J2ME Timermuthusvm
 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptxDilanAlmsa
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in javakamal kotecha
 
Multithreading in Java Object Oriented Programming language
Multithreading in Java Object Oriented Programming languageMultithreading in Java Object Oriented Programming language
Multithreading in Java Object Oriented Programming languagearnavytstudio2814
 
I Need Serious Help with this assignment. Plenty Points to be earned.pdf
I Need Serious Help with this assignment. Plenty Points to be earned.pdfI Need Serious Help with this assignment. Plenty Points to be earned.pdf
I Need Serious Help with this assignment. Plenty Points to be earned.pdfahntagencies
 
A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,Swapnil Dubey
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread poolsmaksym220889
 
PROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part IIPROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part IISivaSankari36
 
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptxnimbalkarvikram966
 

Semelhante a Timer class in java (20)

Session13 J2ME Timer
Session13  J2ME TimerSession13  J2ME Timer
Session13 J2ME Timer
 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptx
 
Java utility classes
Java utility classesJava utility classes
Java utility classes
 
Date class
Date classDate class
Date class
 
Chap2 2 1
Chap2 2 1Chap2 2 1
Chap2 2 1
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
 
Multithreading Concepts
Multithreading ConceptsMultithreading Concepts
Multithreading Concepts
 
Object - Based Programming
Object - Based ProgrammingObject - Based Programming
Object - Based Programming
 
Multithreading in Java Object Oriented Programming language
Multithreading in Java Object Oriented Programming languageMultithreading in Java Object Oriented Programming language
Multithreading in Java Object Oriented Programming language
 
I Need Serious Help with this assignment. Plenty Points to be earned.pdf
I Need Serious Help with this assignment. Plenty Points to be earned.pdfI Need Serious Help with this assignment. Plenty Points to be earned.pdf
I Need Serious Help with this assignment. Plenty Points to be earned.pdf
 
A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,
 
P4
P4P4
P4
 
Threads in Java
Threads in JavaThreads in Java
Threads in Java
 
Slide 7 Thread-1.pptx
Slide 7 Thread-1.pptxSlide 7 Thread-1.pptx
Slide 7 Thread-1.pptx
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread pools
 
Md09 multithreading
Md09 multithreadingMd09 multithreading
Md09 multithreading
 
Unit testing
Unit testingUnit testing
Unit testing
 
Multi threading
Multi threadingMulti threading
Multi threading
 
PROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part IIPROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part II
 
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
 

Mais de Muthukumaran Subramanian (19)

Struts introduction
Struts introductionStruts introduction
Struts introduction
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 
StringTokenizer in java
StringTokenizer in javaStringTokenizer in java
StringTokenizer in java
 
Overriding methods
Overriding methodsOverriding methods
Overriding methods
 
Oops (inheritance&interface)
Oops (inheritance&interface)Oops (inheritance&interface)
Oops (inheritance&interface)
 
Non access modifiers
Non access modifiersNon access modifiers
Non access modifiers
 
Jdbc connectivity in java
Jdbc connectivity in javaJdbc connectivity in java
Jdbc connectivity in java
 
Garbage collection in java
Garbage collection in javaGarbage collection in java
Garbage collection in java
 
Files in java
Files in javaFiles in java
Files in java
 
Exception handling
Exception handlingException handling
Exception handling
 
Currency class
Currency classCurrency class
Currency class
 
Calendar class in java
Calendar class in javaCalendar class in java
Calendar class in java
 
Classes and objects in java
Classes and objects in javaClasses and objects in java
Classes and objects in java
 
intorduction to Arrays in java
intorduction to Arrays in javaintorduction to Arrays in java
intorduction to Arrays in java
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Abstract classes
Abstract classesAbstract classes
Abstract classes
 
Java introduction
Java introductionJava introduction
Java introduction
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
 

Último

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 

Último (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 

Timer class in java

  • 3. Timer class ● The java.util.Timer class provides facility 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.
  • 4. Constructors in Timer class Constructor Description Timer() This constructor creats a new timer Timer(boolean isDaemon) This constructor creates a new timer whose associated thread may be specified to run as a daemon Timer(String name) This constructor creates a new timer whose associated thread has the specified name Timer(String name, boolean isDaemon) This constructor creates a nw timer whose associated thread has the specified name , and may be specified to run as a daemon.
  • 5. Methods in Timer class Methods Description Void cancel() This method terminates this timer,discarding any currently scheduled tasks. Int purge() This method removes all cancelled tasks from this timer's task queue Void schedule(TimerTask task, Date time) This method schedules the specified task for execution at the specified time Void schedule(TiemrTask task, Date firstTime, long period) This method schedules the specified task for repeated fixed-delay execution, beginning at the specified time Void schedule(TimerTask task, long delay) This method schedules the specified task for exectuiton after the specified delay Void schedule(TimerTask task,long delay, long period) This method schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.
  • 6. Cont'd Methods Description Void scheduleAtFixedRate(TimerTask task,Date firstTime,long period) This method schedules the specified task for repeated fixed-rate exectuion, begining at the specified time Void scheduleAtFixedRate(TimerTask task, long delay, long period) This method schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • 7. TimerTask class ● The java.util.TimerTask class represents a task that can be scheduled for one-time or repeated execution by a Timer. protected TimerTask()-This constructor creates a new timer task.
  • 8. Methods in TimerTask class Methods Description Boolean cancel() This method cancels this timer task Abstract void run() This method represents the action to be performed by this timer task. Long scheduledExecutionTime() This method returns the scheduled execution time of the most recent actual execution task
  • 9. Example program using Timer and TimerTask class