Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
16
Task/Concurrent-computing/Pluto/concurrent-computing.pluto
Normal file
16
Task/Concurrent-computing/Pluto/concurrent-computing.pluto
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
local words = {"Enjoy", "Rosetta", "Code"}
|
||||
for h = 1, 3 do
|
||||
local threads = {}
|
||||
for i = 1, 3 do threads[i] = coroutine.create(|| -> print(words[i])) end
|
||||
local called = {false, false, false}
|
||||
local j = 0
|
||||
while j < 3 do
|
||||
local k = math.random(1, 3)
|
||||
if !called[k] then
|
||||
coroutine.resume(threads[k])
|
||||
called[k] = true
|
||||
j += 1
|
||||
end
|
||||
end
|
||||
print()
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue