Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

execution of application at a specific time

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i have written a software and when i click on a button "Start", the software is executed automatically and continue to execute till i dnt exit the software. Now i want to write a code that will lauch the appliaction at a specific time e.g @ 08:00 am and stop it @ 08:00 pm. PLEASE HELP ME OUT. thanks in advance
[ February 11, 2007: Message edited by: Bear Bibeault ]
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using Java 5 and above, then the ScheduledThreadPoolExecutor class is probably what you want. Otherwise, you could also try the Timer class. Both of these support the capability of starting a thread at a particular time.

As for stopping such a thread, I am afraid it will have to be cooperative -- you will need to have your code check, and return, when the finish time arrives.

Henry
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Best approach is to not use Java but to use the facilities of the OS you plan to run on.
reply
    Bookmark Topic Watch Topic
  • New Topic