I have a list and two threads.
One thread can push messages to the list and the other can pop messages
from the list.
So obviously I need to use something like "synchronized" in Java because I
may push a very huge message into the list. If the push is not finished
while the other thread wants to pop...
If I'm right, "@async" can be used to create a thread. So here is what I do:
arrTest = String[]
@async begin
for i = 1 : 100
push!(arrTest, string(i))
end
end
@async begin
if length(arrTest) > 0
pop!(arrTest)
end
end
How to synchronize the push and the pop?