如何在并行红宝石中运行两种方法 [英] How to run two methods in parallel ruby

查看:70
本文介绍了如何在并行红宝石中运行两种方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种方法.第一个远程执行可执行文件,第二个与可执行文件交谈.可执行文件是Web服务.第一步不返回true(通过shell执行),因为它开始并等待第二步.有没有办法并行执行第一种方法和第二种方法?

I have two methods. The first one remotely executes an executable and the second one stars talking with an executable. The executable is a web-service. The first step does not return the true (executed through shell) because it starts and waits for the second step. Is there a way to execute the first method and the second method in parallel?

推荐答案

使用线程.

t1 = Thread.new do
  first_method
end
second_method
t1.join

这篇关于如何在并行红宝石中运行两种方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆