Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Timer help  RSS feed

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i believe that this program should be continue until CTRL +C
but not working in that fashion , please help
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

sparsh khandelwal wrote:
i believe that this program should be continue until CTRL +C
but not working in that fashion , please help


I'm afraid you believe wrong. Read the Javadoc again for the schedule method that takes a TimerTask and a long as parameters.
 
sparsh khandelwal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply
this is the source of the program
timer task program
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

sparsh khandelwal wrote:thanks for your reply
this is the source of the program
timer task program


We don't need to see the source. Your original post showed us the problem - you are assuming the schedule method you are calling does something different to what it actually does. To do what you want to do you need to call one of the other overloaded versions of that method.

I didn't actually look at the RoseIndia link. If it says that the source code you posted should repeatedly run the task, then it is wrong.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Joanne Neal wrote:

sparsh khandelwal wrote:
i believe that this program should be continue until CTRL +C
but not working in that fashion , please help


I'm afraid you believe wrong. Read the Javadoc again for the schedule method that takes a TimerTask and a long as parameters.


Actually I was slightly mistaken. This program will run until Ctrl-C is pressed (because the Timer is never cancelled). It just won't repeatedly print out a message every second as the comment in the code suggests it will.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!