public TransportThread sync() {
        SyncCmd cmd = new SyncCmd();
        if (Thread.currentThread() == thread) {
            log.log(Level.WARNING, "Attempting to sync " + thread + " with itself, which will deadlock");
        }
        if (postCommand(cmd)) {
            cmd.waitDone();
        } else {
            join();
        }
        return this;
    }
Synchronizes with the transport thread. This method will block
until all commands issued before this method was invoked has
completed. If the transport thread has been shut down (or is in
the progress of being shut down) this method will instead wait
for the transport thread to complete, since no more commands
will be performed, and waiting would be forever. Invoking this
method from the transport thread is not a good idea.

@return this object, to enable chaining
jrt/src/com/yahoo/jrt/TransportThread.java