Richard Conroy
12/12/2006 6:22:00 PM
On 12/12/06, Shiwei Zhang <shiwei.zhang@oracle.com> wrote:
> Hi, Richard,
>
> Actually in Ruby, only by the method ".new" we can make threads
> run in parallel rather than serially. And I think it can meet your
> requirement, pls see the programs<multithreads_ProbingHttp.rb> I post at
> the end of this mail, plus the running results.
> Firstly pls notice the following points: 1) The method ".new"
> means "Creates and runs a new thread to execute the instructions given
> in block". 2) The method ".join" means "The calling thread will suspend
> execution and run the called thread. Does not return until the called
> thread exits or until limit seconds have passed".
> ".new" doesn't only mean "creates", it means both "creates" and
> "runs". So ".new" can make son threads run in parallel. And ".join"
> needs to wait for the exit of the called thread, so it gives you the
> illusion that the theads are running serially, but in fact ".join" just
> wraps up the threads. It is inappropriate for us to say whether ".join"
> is making threads run in parallel or serially. We can say ".join" is
> serially waiting for the exits of threads that might be already running
> in parallel. :-) :-)
This is what I noticed. I join up 5 threads at a time, the output jumps
up in batches of 5. This does slow down the algorithm, especially
if there is a lot of positive results - most of these threads are
waiting for the http
connection to timeout.
But I run this thing at night anyway.
As an aside, I have had difficulty getting more than ~ 5 joined threads
to work at all in windows.