Reputation: 11121
I have this block in rufus
def download(log_message)
$logger.info(log_message)
download_all_from_config()
end
scheduler.in '5s' do
first = Thread.new(download("starting cron job (in 5s mode)"))
sleep(55)
second = Thread.new(download("starting 2nd cron job (in 5s mode)"))
first.join
second.join
end
and what I want is to run download_all_from_config() function twice almost simultaneously. This function is downloading big files so I do not want to wait till the fist one finishes. I thought I would use threads but I cannot make it work.
Could someone suggest how to run download_all_from_config() twice so it starts almost simultaneously?
Upvotes: 1
Views: 80
Reputation: 79803
You need to call Thread.new with a block. i.e instead of Thread.new(...)
you need either
Thread.new { ... }
or
Thread.new do
...
end
Upvotes: 3