The problem is that I need to remove an agent from the schedule (I presume that after removing it from the schedule garbage collector will get to it) when his internal condition becomes true. For example, when agent stepped more than 50 times. How do I do that?
Some dirty workaround to this I was able to find is to wrap my agent into another class and put agent = null into the stop() function body. But this is no good, because it leaves wrapper in memory.
I've tried to implement Steppable and Stoppable interfaces to an agent itself and call stop() method the agent, but I can't figure out what to put into the stop() method body, and with empty method it does not work ^^. So when "death" condition becomes true, agent just calls his stop() method over an over again.
Can someone please advice?