From: sheepman Date: 2008-01-18T23:48:50+09:00 Subject: [ruby-dev:33173] should initialize the group of threads こんばんは sheepman です。 2ちゃんねるのスレで見かけたバグです。 ThreadGroup#add がうまく動きません。 $ cat t.rb g = ThreadGroup.new t = Thread.new{sleep 5} z=0 begin g.add t p g.list z+=1 Thread.pass end until g.list.include?(t) p z $ ruby-1.9 -v t.rb ruby 1.9.0 (2008-01-18 revision 0) [i686-linux] [] [] [] [#] 4 以下はパッチです。 $ svn diff thread.c Index: thread.c =================================================================== --- thread.c (revision 15114) +++ thread.c (working copy) @@ -383,7 +383,8 @@ thread_create_core(VALUE thval, VALUE ar th->first_func = fn; th->priority = GET_THREAD()->priority; - + th->thgroup = GET_THREAD()->thgroup; + native_mutex_initialize(&th->interrupt_lock); /* kick thread */ st_insert(th->vm->living_threads, thval, (st_data_t) th->thread_id); -- sheepman / TAMURA Takashi sheepman@sheepman.sakura.ne.jp