Hi @all
I’ve many different threads to run parallel. Some of these have a
special feature. At the starttime, I decide with a variable, which
threads must sleep for 5 ms. The others can start now.

How can I realize this problem??

thanks…

K. R. wrote:

Hi @all
I’ve many different threads to run parallel. Some of these have a
special feature. At the starttime, I decide with a variable, which
threads must sleep for 5 ms. The others can start now.

How can I realize this problem??

thanks…

Thread.new # Look up some uses for it based on what your doing.

as for the variable… wait = sleep(5)

# i assume you meant 5 secs and not 5 milliseconds because i believe

that you cant sleep under 1 second if i remember correctly as sleep does
not allow sleep(0.05)

K. R. wrote:

Hi @all
I’ve many different threads to run parallel. Some of these have a
special feature. At the starttime, I decide with a variable, which
threads must sleep for 5 ms. The others can start now.

How can I realize this problem??

thanks…

Try something like this:

x = 1

10.times do |i|
if my_var < 5
my_var = 10
sleep(0.05)
end

``````puts "thread #{i} executing"
``````

end
end

thr.join
end

–output:–

On Oct 25, 2007, at 7:56 AM, K. R. wrote:

Hi @all
I’ve many different threads to run parallel. Some of these have a
special feature. At the starttime, I decide with a variable, which
threads must sleep for 5 ms. The others can start now.

How can I realize this problem??

threads aren’t quite that deterministic - you may find some without
sleep take longer to start that the ones with the 5ms sleep. what
are you trying to do that requires such strict timing constraints?

regards.

Michael L. wrote:

that you cant sleep under 1 second if i remember correctly as sleep does
not allow sleep(0.05)

It does: ruby’s #sleep calls select() in that case.