I am trying to create 2 threads: thread1 does a process and keyboardThread accepts a user keyboard input. While the thread1 is running no user input should be accepted. When thread1 finishes keyboardThread should be active to accept a user input (for example like "stop"), for a specified given time, when a new thread1 will start, and blocking again user inputs. To pause the keyboardThread a method called pause was created. But how to put all this together? Thanks a lot you guys for your help, luis
here is the code: [ April 02, 2003: Message edited by: Jim Yingst ]
raimondas zemaitis
Ranch Hand
Joined: Feb 23, 2001
Posts: 104
posted
0
I'd suggest you look into "Producer - consumer" example in Java Tutorial at Sun's site. This is almost identical situation with yours.
luis gallo
Greenhorn
Joined: Aug 09, 2001
Posts: 4
posted
0
Thanks I saw that - but I discovered the problem. The System.in stream when closed is closed and you cannot open it any more. That's why I experienced some strange behavior.
Yes, I think closing the reader also closes the stream it was reading. Try just closing the thread itself, or setting some variable in the thread that lets it know the next time it gets info, to ignore the info and just end.