suppose I am working in multiple thread each thread runs following
steps:
step-1
step-2
step-3
step-4
step-5
now I want to make step 2 and step 3 an atomic statement, it means when
one thread goes to statement 2, every other thread should stop and run
only when that particular thread completes step 3. Is it possible? How?
note mutex is not the solution, as mutex keeps thread not running a
block of code at same time, here if one thread goes to the block all
other thread should stop.
On Mon, Nov 26, 2012 at 12:03 PM, ajay paswan [email protected]
wrote:
now I want to make step 2 and step 3 an atomic statement, it means when
one thread goes to statement 2, every other thread should stop and run
only when that particular thread completes step 3. Is it possible? How?
note mutex is not the solution, as mutex keeps thread not running a
block of code at same time, here if one thread goes to the block all
other thread should stop.
Why do you want to do that? That will cripple throughput more than
necessary.
I don’t see how your solution is necessary to solve that.
Cheers
robert
basically I am unable to click a link on ie, so I got an alternating bad
solution (sometimes doesnt work) to focus on link and then clicking. I
don’t want to lose focus of the link before it is clicked due to
multithreading. am I able to make you understand?
On Mon, Nov 26, 2012 at 4:03 AM, ajay paswan [email protected]
wrote:
note mutex is not the solution, as mutex keeps thread not running a
block of code at same time, here if one thread goes to the block all
other thread should stop.
I’m still not sure I entirely understand what you want, but you can make
other threads block on a Queue if you would like for them to wait until
some event has completed.
Alternatively you can use a Mutex + ConditionVariable.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.