Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run two methods in parallel ruby

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?

like image 613
Hu Man Avatar asked Dec 09 '22 16:12

Hu Man


1 Answers

Use thread.

t1 = Thread.new do
  first_method
end
second_method
t1.join
like image 105
sawa Avatar answered Dec 11 '22 08:12

sawa