Roedy Green said:
Thanks for the pointer, but I don't think I have
direct access to the thread. Here is my class which
I got most of from a book. It creates a JLabel and
puts the time of day in it, then updates it every
second. The prio of the thread it creates is 5 and
my graphics stuff runs at 6 (AWT-EventQueue-0) so
often the clock skips a few seconds.
See below the class listing for thread dump.
-------------------
public class ClockLabel extends JLabel implements ActionListener
{
SimpleDateFormat formatter = new SimpleDateFormat("E MM/dd/yy HH:mm:ss");
public ClockLabel(String text, int horizontalAlignment)
{
super(text,horizontalAlignment);
Timer t = new Timer(1000, this);
t.start();
}
public void actionPerformed(ActionEvent e)
{
setText((formatter.format(new Date())).toString());
}
}
--------------------
'd' means daemon, number is prio
Thread Group: system
Thread 0: d 10 Reference Handler
Thread 1: d 8 Finalizer
Thread 2: d 10 Signal Dispatcher
Thread 3: d 10 CompilerThread0
Thread 4: d 6 AWT-Windows
Thread 5: * 6 AWT-EventQueue-0
Thread 6: 5 AWT-Shutdown
Thread 7: d 5 TimerQueue
Thread 8: d 10 Java2D Disposer
Thread 9: 5 DestroyJavaVM