From: James Lavin Date: 2011-09-01T04:18:48+09:00 Subject: Re: Testing threads in RSpec Stefano Crocco wrote in post #1019453: > You should try putting > > thread.join > > instead of sleep. That makes the main thread wait for the thread to > return > before going on. See the ri documentation for Thread#join for more > information. > > I hope this helps > > Stefano Thanks for replying, Stefano. But I DON'T want the main thread to wait for the named thread to return. I want the opposite. Thread#join keeps the named thread alive to completion. This would help if the named thread died faster than the main thread's code executed. In my case, it's the opposite. The named thread (playing a "song") naturally takes longer than the main thread. So I'm not clear how Thread#join would help. My intent (which I should have spelled out) is to have the Jukebox start (but not finish) playing a "song" (for testing purposes, just a "sleep 0.2" or something) and test that it's playing while the thread is running. The "sleep 0.1" makes the main thread wait until the "song" starts playing before testing that it's playing. --James -- Posted via http://www.ruby-forum.com/.