user3241356
user3241356

Reputation: 3

Hashmap,wicket and timer?

At the moment I have a hashamp stores new user registrations that registered on the webpage, however I want to clear the hashmap at 8.00 am in the morning. I can not use java timer as it gives me an error, due to the use of wicket. Can anyone point me in the right direction ? I get the time in millies and compare the dates, however the way my webpage app is set up it would require the user the click refresh at exatcly 8.00 am.

Tnx

                        Timer timer = new Timer ();

            TimerTask hourlyTask = new TimerTask () {
                @Override
                public void run () {
                  sCached=false;

                }
            };
            timer.schedule (hourlyTask, 01, 60);

Upvotes: 0

Views: 270

Answers (1)

Ian Marshall
Ian Marshall

Reputation: 760

One way could be to store somewhere the date-time of the last time the new user registrations hashmap was cleared.

On every read from or write to this hashmap, determine whether this hashmap should have been cleared since this last clearance date-time. If no then do nothing, otherwise clear the hashmap and update the clearance date-time before doing the read or write.

This way, you change how you update the hashmap from a timed basis to an eventing basis.

Upvotes: 1

Related Questions