1) The code as is has a bug .. msgArrived should be AtomicBoolean or volatile or you may get odd results.
2) wait / notify is probably the simplest solution, your inner class (IDataHandler()) should synchronize on a common object and notify when setting the boolean. Then replace the sleep with synchronizing on the same object and a wait (careful with using 'this' for synchronization as new IDataHandler() is an inner class).
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
This can be done with the newer CompletableFuture class. Libraries like guava have similar classes if Java 8 is not available. Create a CompletableFuture inside the checkout method:
Call inside the callback, and outside it to get its value.