Java, replacement for infinite loops?

前端 未结 9 799
花落未央
花落未央 2021-01-13 00:45

I am making a program that shows cellular growth through an array. I have gotten it so when I press the start button, the array updates every 10 seconds in a while(true){} l

9条回答
  •  佛祖请我去吃肉
    2021-01-13 01:21

    What you're looking for is multi-threading. Take the data processing and put it in a second thread, run it asynchronously, and use the main thread to check for user input.

    Of course this might also entail using a semaphore to communicate between the two threads. What level class are you in - have you covered both of these topics already?

提交回复
热议问题