Message Queue for inter-thread communication
Nothing in-depth, just a few things that threw me off as a developer that would be using your class:


If you design a queue, use proper interfaces.
There are a few interfaces in Java, designed to offer standardized access to a Queue

public class MessageQueue&lt;T&gt; { // A queue should implement the Queue&lt;E&gt; interface, preferably BlockingQueue&lt;E&gt;

Mention constants in your documentation, together with their reason.
I have a hard time understanding your limit of 255 messages. As a developer that cannot look at private variables, I would be thrown off with errors once I go over that limit. Document it. Tell others about this limitation!

private static final int MAX_SIZE = 255; // Mention this constant in your documentation

Is there a reason to use the Boolean object type in favor of the boolean primitive? Using Boolean involves unnecessary boxing and might, if used excessively and in time-sensitive applications, introduce lower performance.

public synchronized boolean hasMessage() { // Use primitives when objects are not necessary



This isn't meant as an exhaustive list, but only my subjective opinion.