• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need to change value in HashMap automatically

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a requirement , where a HashMap has some keys and values. To be more specific values are either "true" or "false", I need to change theses values i.e from "true" to "false" or vice versa depending on the time.

Like If there has been more than 30 minutes since the "false" value was inserted , so it should now change to "true" (and vice versa).

I know it can be achieved by a Thread, but is there any other way it can be done , may be through some Java API ???


 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried the quartz schedler.

link to url
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All techniques will use a Thread. If you mean you don't want to create your own background thread and handle the delays yourself etc you could use a java.util.Timer.
For each entry you want to flip every 30 minutes add a TimerTask to the timer. If you want to continue flipping that entry every 30 minutes you can choose either fixed rate or fixed delay depending on your requirements.
 
brevity is the soul of wit - shakepeare. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic