Hey everyone, im working on a game, so i want to have some handles, one for the painting the “Draw method”, other for the logic that usually called “Update Method” , so i want those two methods work for their own, because in this way i will be able to put some loops instructions like for, while in the Update method, without interrupt the painting
i did two threads called PaintHandle and UpdateHandle , and they have a While that called the Draw and the Update method from each Actor
at first was really messy so i put a Thread Delay
private final int DELAY = 40;
public void run(){
while (true) {
for (int i=0 ; i < actors.size() ; i++){
( (Actor)(actors.get(i)) ).update();
}
try{
Thread.sleep(DELAY);
}catch(Exception e){}
}
}
the same with the paint handle, just change the update with draw() , well it work at first, but sometime it get messy again, so i think the thread is to fast or i dont know, so i was wondering, if you recommend to used EventListener insted or a better way
hope you could understand my problem