RE: Something is wrong with my threads

Andy Jones <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <[email protected]>
One post to reply to both Ryan and Marvin:

> What you are doing looks like re-inventing Thread#join. Can't you just use that method?

Good question.  I don't _think_ I can.  I want the code in the thread to be executed IN that thread, not the main one?  Isn't that what #join does? (In MRI this doesn't really matter, but in jRuby it does, and this code has to work in both. See below.)

But it's a moot point in the end, because AFAICS you can't call #join on a stopped thread?  If I swap `run` for `join` I just get "No live threads left. Deadlock? (fatal)"


> Why call Thread.stop, at all? What do you care? This smells of a control issue.

The _real_ code, the one I want to use, is inside an rspec test. It's testing a race condition between multiple threads.  I start 50 threads, give them a time, and then when I restart them they all try and call the same method at that time.  Then I test whether the method screwed up or not.  So, yes, it has control issues.  Testing is all about that ;)

(Obviously this makes no sense at all under MRI because of the GIL.  This is a library that needs to work in jRuby, though.    Perversely, it works fine in jRuby but screws up in MRI...)



Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>

Please note that we have updated our privacy policy in line with new data protection regulations. Please refer to our website to view the ways in which we handle your data.

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.