Posted By:
Edward_Harned
Posted On:
Monday, March 25, 2002 01:35 PM
What you have are two threads. One is the main thread (A); it creates a new thread (B). Both threads share a hashtable. The problem is how does thread (A) know what thread (B) is
doing?
The answer is as old as the first computer with multi-threading/tasking. It is threads talking to each other.
Set up a data structure next to the hashtable that is accessible to both threads. You say thread (B) wakes up periodically, a sleep time I assume.
long sleep_time = 10000L // ten minutes in milliseconds
long last_awake = 0; // last time awake
Now when thread (B) awakens, it updates last_awake with the System.currentTimeMillis().
When thread (A) is curious about the health of thread (B), it can check that the last_awake (plus the sleep_time or something) is reasonable.
This is only one of MANY ways threads can talk to each other.