passing data between threads
I would like to know what is the safest way of communicating between threads in java.
I have four threads that collect udp packets on different ports. I would like the data from all threads written to file through a single thread.
I used a simple communication mechanism using shared object and booleans to wait and exit the synchronized method but this does not seem to work all the time.
I would like to know if there is a safe way of passing arrays between threads and communicating.