@Override public void execute( @Nonnull Runnable command ) { // First do an unsynchronized check to see if a realExecutor is present if ( realExecutor != null ) { realExecutor.execute( command ); return; } // Now do a synchronized check to avoid race conditions synchronized ( this ) { if ( realExecutor != null ) { realExecutor.execute( command ); return; } else { queueRunnable( command ); } } } }
@Override public void execute( @Nonnull Runnable command ) { // First do an unsynchronized check to see if a realExecutor is present if ( realExecutor != null ) { realExecutor.execute( command ); return; } // Now do a synchronized check to avoid race conditions synchronized ( this ) { if ( realExecutor != null ) { realExecutor.execute( command ); return; } else { queueRunnable( command ); } } } }