01: /*
02: * NEMESIS-FORUM.
03: * Copyright (C) 2002 David Laurent(lithium2@free.fr). All rights reserved.
04: *
05: * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
06: *
07: * Copyright (C) 2001 Yasna.com. All rights reserved.
08: *
09: * Copyright (C) 2000 CoolServlets.com. All rights reserved.
10: *
11: * NEMESIS-FORUM. is free software; you can redistribute it and/or
12: * modify it under the terms of the Apache Software License, Version 1.1,
13: * or (at your option) any later version.
14: *
15: * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
16: * application are parts of NEMESIS-FORUM and are distributed under
17: * same terms of licence.
18: *
19: *
20: * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
21: * and software developed by CoolServlets.com (http://www.coolservlets.com).
22: * and software developed by Yasna.com (http://www.yasna.com).
23: *
24: */
25:
26: package org.nemesis.forum.util.cache;
27:
28: /**
29: * Simple timer that keeps the currentTime variable of Cache accurate to one
30: * second of the real clock time.
31: */
32: public class CacheTimer extends Thread {
33:
34: private long updateInterval;
35:
36: /**
37: * Creates a new CacheTimer object. The currentTime of Cache will be
38: * updated at the specified update interval.
39: *
40: * @param updateInterval the interval in milleseconds that updates should
41: * be done.
42: */
43: public CacheTimer(long updateInterval) {
44: this .updateInterval = updateInterval;
45: //Make the timer be a daemon thread so that it won't keep the VM from
46: //shutting down if there are no other threads.
47: this .setDaemon(true);
48: //Start the timer thread.
49: start();
50: }
51:
52: public void run() {
53: //Run the timer indefinetly.
54: while (true) {
55: Cache.currentTime = System.currentTimeMillis();
56: try {
57: sleep(updateInterval);
58: } catch (InterruptedException ie) {
59: }
60: }
61: }
62: }
|