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.
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.