Example usage for java.util.concurrent ExecutorService execute

List of usage examples for java.util.concurrent ExecutorService execute

Introduction

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

Prototype

void execute(Runnable command);

Source Link

Document

Executes the given command at some time in the future.

Usage

From source file:com.netcore.hsmart.smsconsumers.SmsConsumer565.java

public static void main(String args[]) throws Exception {

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new SmsConsumer565Runnable(Integer.toString(i));
        executor.execute(worker);
    }//  w w  w.j a va 2  s  .  c  o m
}

From source file:com.netcore.hsmart.dlrconsumers.DlrConsumer558.java

public static void main(String args[]) throws Exception {

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new DlrConsumer558Runnable(Integer.toString(i));
        executor.execute(worker);
    }/*from w  w  w  .j  a  v a2  s .c o  m*/
}

From source file:com.netcore.hsmart.smsconsumers.SmsConsumer557.java

public static void main(String args[]) throws Exception {

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new SmsConsumer557Runnable(Integer.toString(i));
        executor.execute(worker);
    }/*  w w w . j a v  a 2 s.  co  m*/
}

From source file:com.netcore.hsmart.dlrconsumers.DlrConsumer555.java

public static void main(String args[]) throws Exception {

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new DlrConsumer555Runnable(Integer.toString(i));
        executor.execute(worker);
    }//ww  w. j  a v  a2  s  . co  m
}

From source file:com.netcore.hsmart.dlrconsumers.DlrConsumer557.java

public static void main(String args[]) throws Exception {

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new DlrConsumer557Runnable(Integer.toString(i));
        executor.execute(worker);
    }/*from  w ww .j a  v  a 2s  .co  m*/
}

From source file:com.netcore.hsmart.dlrconsumers.DlrConsumer559.java

public static void main(String args[]) throws Exception {

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new DlrConsumer559Runnable(Integer.toString(i));
        executor.execute(worker);
    }//from   w w w  . j  av a 2 s .  c o m
}

From source file:kymr.github.io.training.scheduler.SchedulerEx1.java

public static void main(String[] args) {
    Publisher<Integer> pub = sub -> {
        sub.onSubscribe(new Subscription() {
            @Override/*  w  w  w.  j a  v  a 2  s .c  om*/
            public void request(long n) {
                log.debug("request()");
                sub.onNext(1);
                sub.onNext(2);
                sub.onNext(3);
                sub.onNext(4);
                sub.onNext(5);
                sub.onComplete();
            }

            @Override
            public void cancel() {

            }
        });
    };

    Publisher<Integer> subOnPub = sub -> {
        ExecutorService es = Executors.newSingleThreadExecutor(new CustomizableThreadFactory() {
            @Override
            public String getThreadNamePrefix() {
                return "subOn-";
            }
        });

        pub.subscribe(new Subscriber<Integer>() {
            @Override
            public void onSubscribe(Subscription s) {
                es.execute(() -> sub.onSubscribe(s));
            }

            @Override
            public void onNext(Integer integer) {
                sub.onNext(integer);
            }

            @Override
            public void onError(Throwable t) {
                sub.onError(t);
                es.shutdown();
            }

            @Override
            public void onComplete() {
                sub.onComplete();
                es.shutdown();
            }
        });
    };

    /*Publisher<Integer> subOnPub = sub -> {
       ExecutorService es = Executors.newSingleThreadExecutor(new CustomizableThreadFactory() {
    @Override
    public String getThreadNamePrefix() {
       return "subOn-";
    }
       });
            
       es.execute(() -> pub.subscribe(sub));
    };
    */
    Publisher<Integer> pubOnPub = sub -> {
        subOnPub.subscribe(new Subscriber<Integer>() {
            ExecutorService es = Executors.newSingleThreadExecutor(new CustomizableThreadFactory() {
                @Override
                public String getThreadNamePrefix() {
                    return "pubOn-";
                }
            });

            @Override
            public void onSubscribe(Subscription s) {
                sub.onSubscribe(s);
            }

            @Override
            public void onNext(Integer integer) {
                es.execute(() -> sub.onNext(integer));
            }

            @Override
            public void onError(Throwable t) {
                es.execute(() -> sub.onError(t));
                es.shutdown();
            }

            @Override
            public void onComplete() {
                es.execute(() -> sub.onComplete());
                es.shutdown();
            }
        });
    };

    pubOnPub.subscribe(new Subscriber<Integer>() {
        @Override
        public void onSubscribe(Subscription s) {
            log.debug("onSubscribe");
            s.request(Long.MAX_VALUE);
        }

        @Override
        public void onNext(Integer integer) {
            log.debug("onNext : {}", integer);
        }

        @Override
        public void onError(Throwable t) {
            log.debug("onError : {}", t);
        }

        @Override
        public void onComplete() {
            log.debug("onComplete");
        }
    });

    log.debug("exit");
}

From source file:com.netcore.hsmart.smsconsumers.SmsConsumer566.java

public static void main(String args[]) throws Exception {

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new SmsConsumer566Runnable(Integer.toString(i));
        executor.execute(worker);
    }//from   w w  w.  j  av a  2s .c  o m
}

From source file:com.netcore.hsmart.dlrconsumers.DlrConsumer556.java

public static void main(String args[]) throws Exception {

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new DlrConsumer556Runnable(Integer.toString(i));
        executor.execute(worker);
    }/*from   w w w .  j a  v  a 2  s  . co  m*/
}

From source file:com.netcore.hsmart.dlrconsumers.DlrConsumer566.java

public static void main(String args[]) throws Exception {

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new DlrConsumer566Runnable(Integer.toString(i));
        executor.execute(worker);
    }/*  www .  ja  v a  2s  .  co  m*/
}