• 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

Storing Timer Objects in a Hashmap

 
Greenhorn
Posts: 6
Windows XP Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im trying to store a series of Timers within a Hashmap for easy reference and retrieval. I will be iterating through a listing of entries that will each get their own Timer and Timertasks associated with them.

What does the syntax look like for putting and getting the timers in the map?

Is there anything I would need to keep in mind when implementing this?
 
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You ought to parameterise the Map object. Why have you marked that Map static?I presume you are familiar with creating and using Timers? I presume you realise there are three kinds of timer, java.util.Timer, javax.management.timer.timer and javax.swing.Timer? You know you can miss out some of the actual type parameters in Java7?
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It does seem slightly odd to put lots of Timers in a Map, though.
 
Herrington Argyle
Greenhorn
Posts: 6
Windows XP Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:
Why have you marked that Map static?
I presume you are familiar with creating and using Timers?
I presume you realise there are three kinds of timer, java.util.Timer, javax.management.timer.timer and javax.swing.Timer?
You know you can miss out some of the actual type parameters in Java7?
It does seem slightly odd to put lots of Timers in a Map, though.


#1: My mistake on the static thing. Ignore that.
#2: I am reletively familiar with using Timers
#3: I should have specified that I was using the java.util.Timer
#4: I'm using Java 6 for this.
#5: I'm only looking after maybe a dozen at best. The ability to cancel and reschedule them individually is the reason for so many of them.

Also, thank you for your help!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic