This is a producer consumer problem in a multi-threaded environment.
Assume that i have multiple consumer (Multiple read threads) and a single producer(write thread). I have a common data structure (say an int variable), being read and written into.
The write to the data sturcture happens occasionally (say at every 2 secs) but read happens contineously.
Since the read operation is contineous and done by multiple threads, making the read method synchronized will add overhead(i.e read operation by one thread should not block the other read threads). But when ever write happens by the write thread, that time the read operations should not be allowed.
Do you want the 'int' to be broadcast to each thread, read by a thread, or is the value just that can be read by multiple threads, multiple times but you don't care how many times in which case you could just make it volatile.
When you say producer, consumer I normally think of messages coming in consumed by one of a pool of threads in which case the java.util.concurrent collections have various queues you can use.
Java has the concept of read and write locks though for efficient use apparently you need a lot more reads than writes which it sounds like you might.
... basically I was a bit confused as to what you actually wanted ;-)
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5