Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
language:java [2026/09/02 03:17] – record pattern, switch pattern ledyxlanguage:java [2026/09/02 04:21] (current) – Virtual Thread ledyx
Line 307: Line 307:
 </sxh> </sxh>
  
 +=== Virtual Thread ===
  
 +"가상 Thread n개 - 플랫폼 Thread 1개 - OS Thread 1개" Mapping 관계
 +
 +여러 요청을 동시에 처리해 전체 처리량을 늘리는 기능.
 +그래서 단일 요청에서 플랫폼 Thread보다 느릴 수 있다.
 +
 +Pooling 방식을 권장하지 않는다. 그때 그때 필요할 때 만들어 사용하라!
 +
 +<sxh java>
 +        /*Thread t = Thread.ofVirtual()
 +                .start(() -> System.out.println("Hello World!"));
 +
 +        t.join();*/
 +
 +        try (ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor()) {
 +            Future<?> future = executorService.submit(() -> System.out.println("Hello, Virtual Thread"));
 +            future.get();
 +        } catch (ExecutionException e) {
 +            throw new RuntimeException(e);
 +        }
 +</sxh>
language/java.txt · Last modified: by ledyx