/** * Performs a blocking get in the UI thread. * * @param supplier will be executed in the UI thread. * @return the value which was returned by supplier. */ public <T> T get(Supplier<T> supplier) { if (Thread.currentThread() == swtThread) { return supplier.get(); } else { Nullable<T> holder = Nullable.ofVolatileNull(); display.syncExec(() -> holder.set(supplier.get())); return holder.get(); } } }
Box.Nullable<String> boxValueNullable = Box.Nullable.ofVolatileNull(); Box.Nullable<String> boxValueNullableFast = Box.Nullable.ofNull(); Box.Nullable<String> boxFromMethodsNullable = Box.Nullable.from(boxValueNullable::get, boxValueNullable::set);