I've got some problems while learning threads in Java. The goal is to make a simulation that shows us how rabbits are running from wolves on some kind of board. Every wolf and every rabbit should be a thread. So I created a GUI in main method of Test class and created a new class that implements the Runnable interface. That's easy and logical I think. But now, how can I call the AddRabbit
method from these threads? Because very thread should do mething like:
- Change its properties like place on the map
- Check other threads place on the map
- Paint itself on the panel
But how?