From: Tobias Peters Date: 2004-08-22T19:26:28+09:00 Subject: Re: Threads + Ncurses Julius Plenz wrote: > But now I have a problem: I want ncurses to draw some things on the > screen and update it every second - until a key is pressed. I'm trying > to do it as follows (short example): > > stop = nil > Thread.new do > until stop > Ncurses.printw("foo") # just an example... > Ncurses.refresh > sleep 1 > end > Ncurses.endwin > end > Ncurses.getch > stop = 1 > > But I suppose Ncurses.getch blocks any other ncurses-functions from > writing anything on the window... so - what to do? > > I just want to run the thread continuously until one key is pressed... > What other possibilities do I have? Ncurses.getch blocks not only other ncurses-functions. It blocks the complete ruby interpreter, all threads. This has to change, obviously, and it will change before the 1.0 release of ncurses-ruby. In the meantime, you can work around the limitation in the way Lennon suggested [ruby-talk:109697]. Even when Ncurses.getch is fixed, you can not expect to call Ncurses functions concurrently from several threads and get the desired results. Ncurses shares this limitation with most other UI libraries. They are basically state machines, i.e. order of commands matters. Your application is responsible for serializing Ncurses calls, not the ncurses wrapper. regards, Tobias