Events: Difference between revisions

m
no edit summary
No edit summary
mNo edit summary
Line 534:
Task one received event.
->
</pre>
 
=={{header|Julia}}==
Julia provides a variety of high and low level functions and macros for mutitasking and events.
The code below uses a Condition() event semaphore created in the base thread for communication
between two child threads.
 
<lang julia>
function dolongcomputation(cond)
det(rand(4000, 4000))
Base.notify(cond)
end
 
function printnotice(cond)
Base.wait(cond)
println("They are finished.")
end
 
function delegate()
println("Starting task, sleeping...")
condition = Base.Condition()
Base.@async(printnotice(condition))
Base.@async(dolongcomputation(condition))
end
 
delegate()
sleep(5)
println("Done sleeping.")
</lang>
{{output}}<pre>
Starting task, sleeping...
They are finished.
Done sleeping.
</pre>
 
4,102

edits