I heard that making calculations in the GUI thread is a bad idea, so what I've thinked about is this:
float someX;
float someY;
Thread t = new Thread(new Runnable() {
//making calculations here, setting someX, someY
})
this.runOnUiThread(new Runnable() {
setX(someX);
setY(someY);
});
thus they are working parallel AND sharing the same variables inside the class, is this the right way to make things move in the screen?
I've thinked to use the AsyncTask
, but is said that is only for short-lived operations...so skiped it
and if the above method is right, why in flash(actionscript) all the calculations are made in the onFrame
event(which I think the GUI thread)?
addEventListener(Event.ENTER_FRAME, function(){
//all is made here
});
of course I know that actionscript is one threaded, just asking
any suggestions or advices please