ruby - 使用 htop 命令可视化 ruby 线程
问题描述
我正在试验 ruby 中的多线程。我运行了这段同时运行 3 个线程的代码(ruby threads.rb
在我的终端中):
arr = []
arr.push(Thread.new do
1000000.times do |i|
puts "thread 1"
end
end)
arr.push(Thread.new do
1000000.times do |i|
puts "thread 2"
end
end)
arr.push(Thread.new do
1000000.times do |i|
puts "thread 3"
end
end)
arr.each {|t| t.join}
我现在htop
在终端的树视图中运行,看看我是否真的可以看到 3 个不同的线程:
我认为线程threads.rb 是突出显示的线程正下方的行,但我看不到我的三个启动线程作为threads.rb 进程的分支。红宝石线程与使用htop 显示的线程和进程无关吗?有没有办法可视化在我的 threads.rb 进程中运行的不同 ruby 线程。
解决方案
推荐阅读
- django - 创建时的 Django 对象未存储在数据库中,并且 ID 返回为 null
- java - 将 Keras 模型导入 DL4J 时出错 - “批量规范层预期输入类型为 CNN、CNN Flat 或 FF...”
- node.js - Nodejs Socket.io 从 on("connection") 事件中获取用户
- matrix - 这是我的数据结构课程的一个问题,我如何输出这个矩阵?
- python - Pandas - 连接两个数据帧,但如果一个数据帧中缺少一列,则用 NaN 填充该列
- python - 匹配两个列表中的相同对象并查看值
- java - 向量中的第二个数组
> 问题 - google-apps-script - TypeError:无法读取 null 的属性“getRange”
- javascript - 使用私有和公共嵌套组件反应路由器单个组件
- firebase - Flutter、Dart、Firestore:如何将从 firestore 检索到的用户数据发送到不同的屏幕?