T
Tobias Merler
I have two threads like show below. In the inner thread I want to wait for user input
from console OR and this is the tricky question alternatively for the change of a
particular contents of a variable in the outer thread (here: variable "state").
If the user enter something or if the contents change
to a special value (e.g. 'a') the inner thread should move on.
If both event are not happening the thread should stay until one of both became true.
How do I implement this most easily with Java ?
char state = 'x';
....
InnerThread = new Thread(new Runnable() {
public void run() {
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
...
option = buf.readLine() || (state == 'a'); <==== This is obviously not working!!
....
} } );
...
state = 'a';
...
Regards
Tobias
from console OR and this is the tricky question alternatively for the change of a
particular contents of a variable in the outer thread (here: variable "state").
If the user enter something or if the contents change
to a special value (e.g. 'a') the inner thread should move on.
If both event are not happening the thread should stay until one of both became true.
How do I implement this most easily with Java ?
char state = 'x';
....
InnerThread = new Thread(new Runnable() {
public void run() {
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
...
option = buf.readLine() || (state == 'a'); <==== This is obviously not working!!
....
} } );
...
state = 'a';
...
Regards
Tobias