Last active
November 4, 2019 15:55
-
-
Save dvas0004/e14374417b99a04fdf22326138290750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.mvc | |
import org.springframework.web.bind.annotation.GetMapping | |
import org.springframework.web.bind.annotation.RestController | |
import java.lang.Thread.sleep | |
import java.util.concurrent.CompletableFuture | |
import java.util.concurrent.ExecutorService | |
import java.util.concurrent.Executors | |
@RestController | |
class Controller { | |
val worker = { | |
sleep(1000) | |
"Done" | |
} | |
private val pool : ExecutorService = Executors.newFixedThreadPool(500) | |
@GetMapping("/asyncTest") | |
fun asyncTest() : CompletableFuture<String> { | |
return CompletableFuture.supplyAsync(worker, pool::execute) | |
} | |
@GetMapping("/syncTest") | |
fun syncTest() : String { | |
return worker() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment