博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lua协程-测试3
阅读量:6913 次
发布时间:2019-06-27

本文共 452 字,大约阅读时间需要 1 分钟。

print("Lua 协程测试3")-- 实现消费者-生产者关系(生产一个就消费一个)count = 10 -- 生产总数-- 生产者local newProductorCo = coroutine.create( --创建协程    function()      local i = 1      while(i <= count)do          coroutine.yield(i) -- 挂起协程          i = i + 1      end    end)-- 消费者for i=1,count do    local status,value = coroutine.resume(newProductorCo)    print(status,value)end运行结果:Lua 协程测试3true    1true    2true    3true    4true    5true    6true    7true    8true    9true    10

 

转载地址:http://fsicl.baihongyu.com/

你可能感兴趣的文章
表单模型+安装目录+侵入表单模型
查看>>
系统如何端子app弄root才干
查看>>
HTML表格边框的设置小技巧
查看>>
jmeter ---模拟http请求/发送gzip数据
查看>>
POJ 2029--Get Many Persimmon Trees +DP
查看>>
Java——复选框:JCheckBox
查看>>
Effective OC : 1-5
查看>>
mock.js 使用教程
查看>>
查看mysql存储引擎
查看>>
关于微信网页调用js-sdk相关接口注意事项目(一级域名与二级域名互相干扰!!!)...
查看>>
第二十三节,不同数据类型在内存中的存址方式,及深浅拷贝
查看>>
PID入门的十五个基本概念
查看>>
用android模拟器Genymotion定位元素
查看>>
eclipse maven build、maven clean、maven install和maven test的区别 精析
查看>>
阿里云 Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR invalid password
查看>>
哈哈,找到一本好书。
查看>>
git使用命令, 特别:git checkout -b a 与 git branch a区别
查看>>
Asp.net网站如何播放Flv视频
查看>>
Windtalkers 风语者
查看>>
mountmust
查看>>