Timer / Thread / animation question

I’m making an ALife game.

In de constructor of my mainframe class I make 2 Timers.
One timertask call calcNewPositions()
the other call putOnScreen()

and I have also a key listener : if you press a button the program will stop.

My problem is that when my clacNewPositions() methode has to do much work (many animals alive) I can’t stop the program anymore and I have to restart my computer.

Is their a simple way so my KeyListener methodes always works. thanks ???

Generally you should make sure that non-event-related threads run with low priority. Don’t know wether this helps in your case.