posted 15 years ago
You didn't ask any question, but here's one thing that I see in this program.
The method message(int n) is synchronized, but that doesn't do anything in this case, because you are creating two distinct Messenger objects. You're starting two threads, and you pass a Messenger object to each of the threads. The threads synchronize on the Messenger objects that you passed to them. But since there are two Messenger objects, each with their own synchronization lock, the two threads will never have to wait for each other.
The synchronization would become important when you would use just one Messenger object: