multithreading - How to share variables between two threads in Java? -


this question has answer here:

i beginner learning java. have question, me solve it? :)

i have class named server maintains hashmap variable, , has 2 methods named send() , receive(). want 2 methods run concurrently. send() method use hashmap variable , receive() method change hashmap variable.

please work out. lot!

define hashmap in main thread spawns send , receive threads. make sure use synchronizedmap don't run race condition.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -