I have the following class:
public class MovementThread extends Thread {
private float[] myObject;
@Override
public void run() {
}
public void setMyObject(float[] array) {
myObject = array;
}
}
The thing is that MovementThread should be running all the time, so I thought about putting a while(true)
in the Run method
. However, myObject
will be updated from another Thread
, so it won't happen if the Thread
is stuck in the Run method
. Also the code in the run method should not be executed when myObject
is being executed.
Is their any non complicated way of doing this ?
I'm just wondering about best practice in this case, which must happen pretty often I reckon.