From: "Jakub PavlĂ­k jn." Date: 2009-01-19T03:04:10+09:00 Subject: Thread starvation Hello, In my game freeVikings [http://freevikings.sf.net] I have code listed below. It uses threads and sometimes problem known as "thread starvation" occurs. Does anyone know some solution? (A more detailed description is under the code listing.) ---------------------------------- def do_loading(&block) Thread.abort_on_exception = true load_t = Thread.new { Thread.current.priority = 1 Thread.stop block.call } progressbar_t = Thread.new { Thread.current.priority = 2 load_t.run loop { paint_loading_screen @app_window, true sleep 0.3 } } load_t.join Thread.kill progressbar_t end ---------------------------------- It's an instance method of class Game and is used in this way: a_game.do_loading { # load something here } Purpose of this method is to show a simple progressbar while doing some long-lasting operation (e.g. loading new level). It creates two threads: load_t, in which given block is executed and progressbar_t, which regularly calls Game#paint_loading_screen (method, which repaints loading screen with progressbar). Thread progressbar_t has higher priority, because I need it to be called often and not to e.g. wait for load_t's end. Unfortunatelly from time to time Thread load_t is somehow "suspended" - progressbar shows progress on and on, but nothing happens. I think it's a case of so called "thread starvation" and would be very glad to know how to avoid it. Thank you very much. Jakub Pavlik -- "Configure complete, now type 'make' and PRAY." (configure script of zsnes - www.zsnes.com)