@SuppressWarnings("unchecked") private <U, V> V execute(U inputParameter, ProcessDescription<U, V> processDescription, Executor executorService) throws InterruptedException, ExecutionException { if (processDescription.getThreadType().equals(ThreadType.EXECUTOR)) { FutureTask<V> task = new FutureTask<V>(() -> { return processDescription.getFunction().apply(inputParameter); }); executorService.execute(task); return task.get(); } else { return ConcurrentUtils.runCallableAndWait(() -> { return processDescription.getFunction().apply(inputParameter); }); } }
if (eventProducer.getThreadType().equals(ThreadType.EXECUTOR)) { ObservableExecutor.getDefaultInstance().execute(() -> { EventSystem.getInstance().send(eventProducer.getAdress(), eventProducer.getContentSupplier().get());
/** * Registers a receiver for all events that will be send to the given <tt>adress</tt>. The receiver can get * the events on the JavaFX application thread or on a background thread. * @param address the adress * @param receiver the receiver * @param type defines if the receiver will get the events on the JavaFX application thread or on * a background thread. */ public void addReceiver(String address, Consumer<Event> receiver, ThreadType type) { if (type.equals(ThreadType.EXECUTOR)) { if (!asyncConsumers.containsKey(address)) { asyncConsumers.put(address, FXCollections.observableArrayList()); } asyncConsumers.get(address).add(receiver); } else { if (!consumers.containsKey(address)) { consumers.put(address, FXCollections.observableArrayList()); } consumers.get(address).add(receiver); } }