A thread T1 will put a value with a key to HashMap in the Singleton DataMap and then another thread (or the same thread) T2 will get the value by using the key after several minutes. T2 may not get a value from HashMap.
T1 and T2 threads are not in the same ThreadGroup.
So should I add an object lock to synchronize the method "get" and "put"?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
If just synchronizing put and get doesn't solve your problem, you should google for the "Producer Consumer" pattern.
Originally posted by Jon Egan:
Can someone who is more current on this confirm or deny that, and recommend a solution? Seems like catch-22 to me, at the moment: how do you guarantee the order of operations (waits and notifies) between threads, so that you know the mechanism for guaranteeing the order of operations (writes and reads) will work?
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |