I'm new on Multithreading and Synchronization in Java Android. As I known, Synchronization is usually use in Multithreading to deal with 'shared object' among these Multithreading. Also, Multithreading mean that many threads run parallel at the time.
My problem is, for example:
I have 2 object: cookie and monter.
Monter need eat cookie, then consume it in random speed time (not exceed 5s).
So, I have a small game: In 2 minutes. Two monter compete on eat cookie (Once eat 1 cookie, consume it). The contest's winner is determined as the monster that has eaten the most cookies in two minutes.
More detail. Cookie is likely 'shared object' and 2 monter is Multithreading
So, How to i make the game or simply how to i do maintain Threads (Loop: do and delay - eat and consume) in Java.