GroupChat History message order

Hello,

When I try a MUC groupchat and receive the history the messages sometimes come in a wrong order. This happens only sometimes and the order is random. Any idea whats going on there?I debug openfire3.6.4 the sound code, found sends a historic record after the LocalMUCRoom.java joinRoom() method, Thread.sleep(1000), the historical demonstration is correct. why? And how do I solve it?

if (historyRequest == null) {
            Iterator history = roomHistory.getMessageHistory();
            while (history.hasNext()) {
                /**original is:
                 *joinRole.send( (Message) history.next());
                 *
                 */                 Message m = (Message) history.next();
                Log.info("@@@@@@@@@@@@@@@@"+m.toXML());
                joinRole.send(m);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                                    }
            }
        }

PATCH: CM out of order messages (plus more)
http://community.igniterealtime.org/message/204016#204016