2008/10/10
<>:
> However I
> still believe this is a bad design decision on behalf of thread
> creation with ruby. ... Anyone have any opinions
> on the subject?
There's nothing special going on. If you override a method in a
subclass, the original method is called if and only if you call super.
It would be a *very* bad design decision to deviate from this simple
and clear principal.
The task of the original Thread#initialize method is to spawn a new
thread and call the given block in the new thread. If you override the
#initialize method in your subclass and don't call super, then no new
thread is created (who should do this and when ???). So it's your
responsibility to invoke the original method when it's appropriate for
your subclass. Since you obviously want to initialize some instance
variables before spawning the new thread, you should call super after
the initialization of your instance variables. If you want to do
something after spawning the new thread, you would put this code after
the call to super. As I said: there's nothing special with class
Thread. It behaves as every other class in Ruby.
Regards,
Pit