Difference between join and ThreadsWait.all_waits

L

Lloyd Zusman

Consider the following two examples:

1. Using join:

threadlist = []

ARGV.each {
|arg|
threadlist << Thread.new(arg, &aThreadProc)
}

threadlist.each { |t| t.join }

exit(0)

2. Using ThreadsWait:

require 'thwait'

threadlist = []

ARGV.each {
|arg|
threadlist << Thread.new(arg, &aThreadProc)
}

ThreadsWait.all_waits(threadlist)

exit(0)

Is there any difference between these two ways of doing this?

Is the only advantage of the 'ThreadsWait#all_waits' method over 'join'
the fact that the former allows for an optional proc to be invoked to
clean up after each thread when it terminates?

I realize that the ThreadsWait class has other useful methods. I'm just
asking specifically about its 'all_waits' method.

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top