You must write 2 threads. Flow A with a periodicity of 10 seconds will switch from the “allowed” state to the “not allowed” state, and 2 threads that will wait for the status of the Flow A “allowed” and start counting from 10, and stop their action as soon as the state of the flow A changes to not allowed state. How best to do this. I thought that in the flow A to introduce a variable value of which will change. But how can I then determine the current value of the variable A in stream B? Advise in which direction to dig or how best to do it. Thank you in advance. Flow Code A:
class A extends Thread{ public boolean isAllowed=false; A(){ } public void run(){ for(int i=0; i<10; i++){ try { Thread.sleep(10000); isAllowed=true; } catch (InterruptedException e) { System.err.println(e); } } } }
Bto classA, and when you consider that the state is “allowed”, in classApull the callback, and in classBalready perform the necessary actions. - Peter Samokhin