1
如何定義Thread#initialize
?我嘗試以下:定義`Thread#initialize`
(1)
class Thread
def initialize
super
@foo = []
end
end
Thread.new{}.join
(2)
class Thread
def initialize &pr
super(&pr)
@foo = []
end
end
Thread.new{}.join
(3)
class Thread
def initialize
end
end
Thread.new{}.join
但是它們返回一個錯誤:
Uninitialized thread - check `Thread#initialize'.
你不應該重寫默認主題#初始化。如果你只是使用內置方法會發生什麼? – echristopherson 2013-05-12 17:47:25