From: John Briggs Date: 2010-04-21T23:25:05+09:00 Subject: Ruby 1.9.1, Threads and "[BUG] The handle is invalid." Hi! I am new to this forum so this is my first post. I have Ruby 1.9.1 on Windows 7 and I am trying to make a program that will do some jobs in threads. A simplified version of what I want to do would look like this: $threads_alowed = 700; $threads = [] $threads_alowed.times{|thread_id| $threads[thread_id] = {'thread' => Thread.new{}} puts "thID #{thread_id} initialized" } def do_something(thread_id) wait = rand(300) print "\nThread #{thread_id} is doing something for #{wait} seconds" sleep wait end while true do $threads_alowed.times{|thread_id| status = $threads[thread_id]['thread'].status if status == false or status == nil $threads[thread_id]['thread'] = Thread.new(thread_id){do_something(thread_id)} print "," end } print "." sleep 0.03 end It seems to work but often I get the following error: [BUG] The handle is invalid. ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32] -- control frame ---------- --------------------------- -- Ruby level backtrace information----------------------------------------- [NOTE] You may encounter a bug of Ruby interpreter. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. and all the script crashes. I tried to run the same script on CentOS and it is working without problems, but I can not stick to just one OS. I need this script to work on every OS that Ruby runs on. So my question is: Does anybody know how to get rid of this error on windows or maybe any workaround and what this error mean? -- Posted via http://www.ruby-forum.com/.