Skip to content

Instantly share code, notes, and snippets.

@pvllnspk
Last active January 7, 2018 21:05
Show Gist options
  • Select an option

  • Save pvllnspk/45e9f51150a62b5252656f3e2d806be4 to your computer and use it in GitHub Desktop.

Select an option

Save pvllnspk/45e9f51150a62b5252656f3e2d806be4 to your computer and use it in GitHub Desktop.

Revisions

  1. pvllnspk revised this gist Jan 7, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions threads
    Original file line number Diff line number Diff line change
    @@ -18,8 +18,7 @@ for (int i = 0; i < n; ++i) {
    }

    3.
    Observable.zip(, ,
    new BiFunction() {
    Observable.zip( , ,new BiFunction() {
    @Override
    public List<User> apply() throws Exception {
    }
  2. pvllnspk revised this gist Jan 7, 2018. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion threads
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,13 @@ for (int i = 0; i < n; ++i) {
    Future<String> result = executorCompletionService.take();
    }

    3.
    3.
    Observable.zip(, ,
    new BiFunction() {
    @Override
    public List<User> apply() throws Exception {
    }
    })
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(getObserver());
  3. pvllnspk revised this gist Jan 7, 2018. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion threads
    Original file line number Diff line number Diff line change
    @@ -12,5 +12,9 @@ List<Future<String>> results = executorService.invokeAll(callables);
    for(Future<String> future: results){
    result+= future.get();
    }


    for (int i = 0; i < n; ++i) {
    Future<String> result = executorCompletionService.take();
    }

    3.
  4. pvllnspk revised this gist Jan 7, 2018. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions threads
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,12 @@
    }

    2.
    List<Callable<String>> callables = ...
    List<Future<String>> results = executorService.invokeAll(callables);
    String result = executorService.submit(callable).get();

    List<Callable<String>> callables = ...
    List<Future<String>> results = executorService.invokeAll(callables);
    for(Future<String> future: results){
    result+= future.get();
    }
    }

    3.
  5. pvllnspk revised this gist Jan 7, 2018. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion threads
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,11 @@
    for(int i = 0; i < threads.size(); i++) {
    threads.get(i).start();
    threads.get(i).join();
    }
    }

    2.
    List<Callable<String>> callables = ...
    List<Future<String>> results = executorService.invokeAll(callables);
    for(Future<String> future: results){
    result+= future.get();
    }
  6. pvllnspk created this gist Jan 7, 2018.
    5 changes: 5 additions & 0 deletions threads
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    1.
    for(int i = 0; i < threads.size(); i++) {
    threads.get(i).start();
    threads.get(i).join();
    }