Kotlin vs Java

I
Java
public CompletableFuture<SomeOtherResult> doBothAsync(){
    doSomethingAsync()
        .thenAcceptBoth(doSomethingElseAsync()) (
                (one, two) -> {
            // combine results of both calls here
        )}
}


public CompletableFuture<SomeOtherResult> doSequentiallyAsync() {
    doSomethingAsync().thenCompose(
        something -> {
            doSomethingElseAsync(something)
    })
}
Kotlin
suspend fun doSequentially() {
    val something = doSomething()
    doSomethingElse(something)
}

suspend fun doBoth() = coroutineScope {
    val deferredOne = async { doSomething() }
    val two = doSomethingElse() // while doSomething is working
    val one = deferredOne.await()
    // combine results of both calls here
}
II
Java
public <T> CompletableFuture<T> inTransaction(DatabaseFunction<T> fun) {
    return CompletableFuture
    .runAsync(() -> this.sendQuery("BEGIN"))
    .thenApply(ignored -> fun.execute(this))
    .thenApply(s -> {
        this.sendQuery("COMMIT");
        return s;
    })
        .exceptionally(throwable -> {
        this.sendQuery("ROLLBACK");
        return null;
    });
}
Kotlin
suspend fun <T> inTransaction(
    f: suspend (Connection) -> T): T {
    try {
        this.sendQuery("BEGIN")
        val result = f(this)
        this.sendQuery("COMMIT")
        return result
    } catch (e: Throwable) {
        this.sendQuery("ROLLBACK")
        throw e
    }
}

III
Java
final var callables = Stream.of("Service A", "Service B", "Service C")
        .map(DummyService::new)
        .map(service -> (Callable<ContentDuration>) service::getContent)
        .collect(Collectors.toList());

final var executor = Executors.newWorkStealingPool();
final var results = executor.invokeAll(callables).stream()
    .map(
        future -> {
             try {
                 return future.get();
             } catch (InterruptedException | ExecutionException e) {
                 throw new RuntimeException(e);
             }
        }
    ).collect(Collectors.toList());
Kotlin
val DummyService.asyncContent: Deferred<ContentDuration>
    get() = async(CommonPool) { content }

var results = runBlocking {
    arrayOf("Service A", "Service B", "Service C")
        .map { DummyService(it) }
        .map { it.asyncContent }
        .map { it.await() }
}