This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| language:java [2026/09/02 03:17] – record pattern, switch pattern ledyx | language:java [2026/09/02 04:21] (current) – Virtual Thread ledyx | ||
|---|---|---|---|
| Line 307: | Line 307: | ||
| </ | </ | ||
| + | === Virtual Thread === | ||
| + | " | ||
| + | |||
| + | 여러 요청을 동시에 처리해 전체 처리량을 늘리는 기능. | ||
| + | 그래서 단일 요청에서 플랫폼 Thread보다 느릴 수 있다. | ||
| + | |||
| + | Pooling 방식을 권장하지 않는다. 그때 그때 필요할 때 만들어 사용하라! | ||
| + | |||
| + | <sxh java> | ||
| + | /*Thread t = Thread.ofVirtual() | ||
| + | .start(() -> System.out.println(" | ||
| + | |||
| + | t.join();*/ | ||
| + | |||
| + | try (ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor()) { | ||
| + | Future<?> | ||
| + | future.get(); | ||
| + | } catch (ExecutionException e) { | ||
| + | throw new RuntimeException(e); | ||
| + | } | ||
| + | </ | ||