logo
  • 教程列表
  • SO官方文檔
  • 佇列
    • 多個工人一個接收器
    • 將佇列轉換為陣列
    • 一個來源多個工人
    • 一個來源 - 工作流水線 - 一個水槽
    • 將資料推入佇列 - 推送
    • 從佇列中提取資料 - 彈出
    • 同步 - 在某個時間點之後
    • 合併兩個佇列
  1. StackOverflow 文件
  2. Ruby Language 教程
  3. 佇列
  4. 同步 - 在某個時間點之後

同步 - 在某個時間點之後

Created: November-22, 2018

syncer = Queue.new

a = Thread.new do
  syncer.pop
  puts "this happens at end"
end

b = Thread.new do
  puts "this happens first"
  STDOUT.flush
  syncer << :ok
end

[a, b].map(&:join)
  • 合併兩個佇列
  • 從佇列中提取資料 - 彈出

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明