From: "yermej@..." Date: 2007-09-30T16:15:11+09:00 Subject: Re: Subclassing Thread? On Sep 30, 1:55 am, Stephen Ware wrote: > Is it possible to launch a Ruby thread without passing a block to > Thread.new? > > Those familiar with threading in Java will know that you can write a > class that is a subclass of Thread, and then put the thread's code into > 'public static void run,' which gets executed once thread.start is > called. Can something similar to this be done in Ruby? > > Basically, I want to write a Ruby class that is subclass of thread, and > whose 'initialize' method is called when it is created. Can it be done? > > Thanks, > Stephen > -- > Posted viahttp://www.ruby-forum.com/. This seems to work: class MyThread < Thread def initialize super("purple monkey dishwasher") {|str| puts "She said, '#{str}.'"} end end > MyThread.new She said, 'purple monkey dishwasher.' => # Adjust arguments to #initialize as needed. Jeremy