Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

➔ Software developer - Team lead ➔ Java Champion ➔ Medellin Java Users Group Leader ➔ hibernate/hibernate-validator Contributor ➔ Duke’s Choice Award Winner ➔ Eclipse Collections contributor

Slide 3

Slide 3 text

➔ Professional with 10+ years ➔ Principal Software Engineer - NY ➔ NYJavaSIG Leader ➔ graciano.dev ➔ Twitter: @rodrigograciano

Slide 4

Slide 4 text

● ● ● ●

Slide 5

Slide 5 text

● Concurrency when we have many task, largely independent, and we use the same resource to do them at a time ● Parallelism is when we want to do one task, and we split up in multiple subtasks

Slide 6

Slide 6 text

A Thread is an independent path of execution that allows a program to operate more efficiently by doing multiple things at the same time. Threads can be used to perform complicated tasks in the background without interrupting the main program.

Slide 7

Slide 7 text

● Synchronous: when we wait to finish a task before moving to the next one ● Asynchronous: when we move to another task before it finishes

Slide 8

Slide 8 text

● Thread t = new Thread( ()-> this.doSomething( thing )); t.start(); ● ExecutorService executor = Executors.newFixedThreadPool( 10 ); Future> future = executor.submit( ()-> this.doSomething( thing )); ● CompletableFuture.runAsync( ()-> this.doSomething( thing )); ● Thread.builder().virtual().name("name").task(() -> this.doSomething( thing )).start();

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Stream API CompletableFuture Creation Chained operations Return forEach runAsync thenAccept / thenRun void map supplyAsync thenApply CompletableFuture

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

CompletableFuture::runAsync (Runnable runnable) CompletableFuture::supplyAsync (Supplier supplier) CompletableFuture::runAsync (Runnable runnable, Executor executor) CompletableFuture::supplyAsync (Supplier supplier, Executor executor)

Slide 14

Slide 14 text

static ExecutorService newCachedThreadPool() static ExecutorService newFixedThreadPool (int nThreads) static ScheduledExecutorService newScheduledThreadPool (int corePoolSize) static ExecutorService newSingleThreadExecutor() static ScheduledExecutorService newSingleThreadScheduledExecutor() static ExecutorService newWorkStealingPool()

Slide 15

Slide 15 text

T::get () throws InterruptedException , ExecutionException T::get (long timeout, TimeUnit unit) throws InterruptedException , ExecutionException , TimeoutException T::getNow (T valueIfAbsent) T::join()

Slide 16

Slide 16 text

● ● ● ●