6 Star 28 Fork 14

Julia语言程序设计 / bookexamples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
demo_ch1.jl 439 Bytes
一键复制 编辑 原始数据 按行查看 历史
魏坤 提交于 2018-08-18 11:48 . 适配v1.0
using Distributed
function putter(c::Channel)
println("putting...")
for i = 1:5
put!(c, i)
t = rand()
println("Put ", i, "\t sleep ", t)
sleep(t)
end
end
function taker(c::Channel)
println("taking...")
while true
x = 0
t = @elapsed x = take!(c)
println("Take ", x, "\t elapsed ", t)
end
end
c = Channel(2)
@async taker(c)
putter(c)
read(stdin, Char)
Julia
1
https://gitee.com/juliaprog/bookexamples.git
git@gitee.com:juliaprog/bookexamples.git
juliaprog
bookexamples
bookexamples
master

搜索帮助