• Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing Timer Objects in a Hashmap  RSS feed

 
Herrington Argyle
Greenhorn
Posts: 6
Suse Windows XP
  • Mark post as helpful
  • send pies
  • 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?
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does seem slightly odd to put lots of Timers in a Map, though.
 
Herrington Argyle
Greenhorn
Posts: 6
Suse Windows XP
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!