Example usage for java.util.concurrent ForkJoinTask ForkJoinTask

List of usage examples for java.util.concurrent ForkJoinTask ForkJoinTask

Introduction

In this page you can find the example usage for java.util.concurrent ForkJoinTask ForkJoinTask.

Prototype

ForkJoinTask

Source Link

Usage

From source file:org.diorite.utils.concurrent.ParallelUtils.java

public static ForkJoinTask<Void> createSimpleTask(final Runnable runnable) {
    return new ForkJoinTask<Void>() {
        @Override/* ww w .ja  v a 2  s  .c  om*/
        public Void getRawResult() {
            return null;
        }

        @Override
        protected void setRawResult(final Void value) {
        }

        @Override
        protected boolean exec() {
            runnable.run();
            return true;
        }
    };
}

From source file:org.diorite.utils.concurrent.ParallelUtils.java

public static ForkJoinTask<Void> createSimpleTask(final Supplier<Boolean> runnable) {
    return new ForkJoinTask<Void>() {
        @Override/*  ww  w .  j  a v a 2 s.  co  m*/
        public Void getRawResult() {
            return null;
        }

        @Override
        protected void setRawResult(final Void value) {
        }

        @Override
        protected boolean exec() {
            return runnable.get();
        }
    };
}

From source file:org.diorite.utils.concurrent.ParallelUtils.java

public static <T> ForkJoinTask<T> createTask(final Supplier<T> runnable) {
    return new ForkJoinTask<T>() {
        private T result;

        @Override//from w w  w.  j  av a 2  s . c  o  m
        public T getRawResult() {
            return this.result;
        }

        @Override
        protected void setRawResult(final T value) {
            this.result = value;
        }

        @Override
        protected boolean exec() {
            this.result = runnable.get();
            return true;
        }
    };
}