1 /*********************************************************************
5 * Purpose : Part of the StatWidget, the thread that manages the
6 * timing of the swatch of color.
8 * Copyright : Written by and Copyright (C) 2003 the SourceForge
9 * Privoxy team. http://www.privoxy.org/
11 * Based on the Internet Junkbuster originally written
12 * by and Copyright (C) 1997 Anonymous Coders and
13 * Junkbusters Corporation. http://www.junkbusters.com
15 * This program is free software; you can redistribute it
16 * and/or modify it under the terms of the GNU General
17 * Public License as published by the Free Software
18 * Foundation; either version 2 of the License, or (at
19 * your option) any later version.
21 * This program is distributed in the hope that it will
22 * be useful, but WITHOUT ANY WARRANTY; without even the
23 * implied warranty of MERCHANTABILITY or FITNESS FOR A
24 * PARTICULAR PURPOSE. See the GNU General Public
25 * License for more details.
27 * The GNU General Public License should be included with
28 * this file. If not, you can view it at
29 * http://www.gnu.org/copyleft/gpl.html
30 * or write to the Free Software Foundation, Inc., 59
31 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 *********************************************************************/
37 package org.privoxy.activityconsole;
43 * The thread that manages the timing of the swatch of color of the StatWidget.
44 * @author Last Modified By: $Author$
45 * @version $Rev$-$Date$$State$
47 public class StatWidgetThread extends Thread
49 private static final String
50 COPYRIGHT = org.privoxy.activityconsole.Copyright.COPYRIGHT;
52 int _statusDurationMillis = 0;
53 Date _nextUpdate = null;
54 StatWidget _parent = null;
56 public StatWidgetThread(StatWidget parent, int statusDurationMillis)
59 _statusDurationMillis = statusDurationMillis;
62 public final void run()
64 boolean snooze = false;
69 /* Check once before we wait at all, just in case... */
70 if (_nextUpdate != null)
71 snooze = checkTimer();
73 sleepFor = _statusDurationMillis;
75 sleepFor = 540000 + (int)(Math.random() * 60000); /* Sit around for 10 minutes plus or minus a minute */
79 if (_nextUpdate != null)
80 snooze = checkTimer();
92 _nextUpdate = new Date(new Date().getTime() + _statusDurationMillis);
95 public boolean checkTimer()
97 boolean returnVal = true;
98 Date now = new Date();
99 if (now.after(_nextUpdate))