{"id":457651,"date":"2025-04-28T03:10:08","date_gmt":"2025-04-28T03:10:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=457651"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=457651","title":{"rendered":"<span>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c JEP 491 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0414\u0435\u043d\u043e\u043c \u0412\u0435\u0433\u043e\u0439<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/49d\/549\/4a0\/49d5494a0d47a5b9b8b326cd6599aecd.png\" width=\"1536\" height=\"1024\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/49d\/549\/4a0\/49d5494a0d47a5b9b8b326cd6599aecd.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/49d\/549\/4a0\/49d5494a0d47a5b9b8b326cd6599aecd.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u0434\u0435\u0432\u0435\u043b\u043e\u043f\u0435\u0440 \u0430\u0434\u0432\u043e\u043a\u0430\u0442\u043e\u0432 Spring Framework, \u0414\u0435\u043d \u0412\u0435\u0433\u0430, \u043d\u0430\u00a0\u0434\u043d\u044f\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u043e\u0441\u0442 \u0432\u00a0\u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u0443\u044e \u0441\u043e\u0446\u0441\u0435\u0442\u044c, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0437\u0443\u0447\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0443 JEP 491\u00a0\u2014 Synchronize Virtual Threads without Pinning. \u0410\u0432\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u043b \u043d\u0435\u0437\u0430\u0442\u0435\u0439\u043b\u0438\u0432\u044b\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442, \u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0442 JEP \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d \u043d\u0435 \u0431\u044b\u043b. <a href=\"https:\/\/github.com\/danvega\/pinning\"><em>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/em><\/a> \u0441 \u043a\u043e\u0434\u043e\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u043b\u0441\u044f. \u0410\u0432\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u0432 \u0447\u0435\u043c \u0442\u0443\u0442 \u0434\u0435\u043b\u043e&#8230; \u0438 \u044f \u0432\u044b\u044f\u0441\u043d\u0438\u043b.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/706\/107\/afd\/706107afdb0ff85c706ec52a674efa24.png\" width=\"1174\" height=\"1084\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/706\/107\/afd\/706107afdb0ff85c706ec52a674efa24.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/706\/107\/afd\/706107afdb0ff85c706ec52a674efa24.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0432 \u0447\u0435\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0443\u0442\u044c JEP. \u0420\u0430\u043d\u0435\u0435, <code>synchronized<\/code> \u0431\u043b\u043e\u043a &#8216;\u043f\u0440\u0438\u0448\u0438\u0432\u0430\u043b&#8217; \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0440\u0435\u0434 \u043a \u0442\u0440\u0435\u0434\u0443 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044e. \u0418\u043d\u043e\u0433\u0434\u0430, \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u043e \u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u043e \u044d\u0442\u043e \u0431\u044b\u043b \u043e\u0434\u0438\u043d \u0438\u0437 <a href=\"https:\/\/habr.com\/ru\/companies\/spring_aio\/articles\/838912\/\">\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432<\/a> \u0432 \u043d\u0430\u0448\u0435\u043c \u0431\u043b\u043e\u0433\u0435. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Java 24 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043d\u0435\u0442 \u0438 <code>synchronized<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0440\u0435\u0434\u0430\u043c\u0438 \u0431\u0435\u0437 \u043e\u043f\u0430\u0441\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0414\u0435\u043d \u0412\u0435\u0433\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044f, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c <code>synchronized<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0435\u0434\u043e\u0432 \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0438\u0441\u0442\u043e\u0449\u0435\u043d\u0438\u0435 \u043f\u0443\u043b\u0430 \u0442\u0440\u0435\u0434\u043e\u0432-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u0439. \u041a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442, \u043a\u0430\u043a \u0442\u0440\u0438 \u043a\u043e\u043f\u0435\u0439\u043a\u0438. \u0412 \u0446\u0438\u043a\u043b\u0435 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435: <\/p>\n<p>1. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 <br \/>2. \u0414\u0435\u043b\u0430\u044e\u0442 <code>Thread.sleep()<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 <code>synchronized<\/code> \u0431\u043b\u043e\u043a\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package dev.danvega;  import java.time.Duration; import java.time.Instant; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger;  public class Application {     private static final int NUM_THREADS = 5000; \/\/ Increased threads    private static final long BLOCKING_TIME_MS = 5; \/\/ Shorter sleep inside lock    private static final int CPU_WORK_ITERATIONS = 10000; \/\/ Work *outside* lock     private static final Object lock = new Object();    private static final AtomicInteger completedTasks = new AtomicInteger(0);    private static volatile double busyWorkSink = 0; \/\/ To prevent dead code elimination     \/\/ Simple CPU-bound work    private static void doCpuWork() {       double result = 0;       for (int i = 0; i &lt; CPU_WORK_ITERATIONS; i++) {          result += Math.sin(i) * Math.cos(i);       }       \/\/ Use the result to prevent optimization       busyWorkSink += result;    }     public static void main(String[] args) throws InterruptedException {       System.out.println(\"Running with Java version: \" + System.getProperty(\"java.version\"));       System.out.printf(\"Launching %,d virtual threads...\\n\", NUM_THREADS);       System.out.printf(\"Each thread does CPU work (%,d iterations), then acquires lock and blocks for %d ms.\\n\",               CPU_WORK_ITERATIONS, BLOCKING_TIME_MS);        ThreadFactory factory = Thread.ofVirtual().factory();       try (var executor = Executors.newThreadPerTaskExecutor(factory)) {           Instant start = Instant.now();           for (int i = 0; i &lt; NUM_THREADS; i++) {             executor.submit(() -&gt; {                try {                   \/\/ This work can run concurrently if carrier threads are available.                   doCpuWork();                   synchronized (lock) {                      \/\/ Short sleep *inside* the lock                      \/\/ JDK 21: Pins carrier, making it unavailable for others' doCpuWork()                      \/\/ JDK 24: Unmounts carrier, allowing it to run others' doCpuWork()                      Thread.sleep(Duration.ofMillis(BLOCKING_TIME_MS));                   }                   completedTasks.incrementAndGet();                } catch (InterruptedException e) {                   Thread.currentThread().interrupt();                   System.err.println(\"Thread interrupted: \" + e.getMessage());                } catch (Exception e) {                   System.err.println(\"Error in task: \" + e.getMessage());                   e.printStackTrace(); \/\/ Print stack trace for unexpected errors                }             });          }           executor.shutdown();          boolean finished = executor.awaitTermination(5, TimeUnit.MINUTES);           Instant end = Instant.now();          Duration duration = Duration.between(start, end);           if (finished) {             System.out.printf(\"All %,d tasks completed.\\n\", completedTasks.get());             System.out.printf(\"Total execution time: %.3f seconds\\n\", duration.toMillis() \/ 1000.0);          } else {             System.err.printf(\"Executor timed out after 5 minutes. Tasks completed: %,d\\n\", completedTasks.get());          }       }       System.out.println(\"----------------------------------------\");       \/\/ Print sink value to ensure work wasn't optimized away       \/\/ System.out.println(\"Sink value (ignore): \" + busyWorkSink);    } }<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0427\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c<\/h2>\n<p>\u0410\u0432\u0442\u043e\u0440 \u043e\u043f\u0438\u0441\u0430\u043b \u0441\u0432\u043e\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0432\u043d\u0443\u0442\u0440\u0438 <code>synchronized<\/code> \u0431\u043b\u043e\u043a\u0430.<\/p>\n<pre><code class=\"java\">synchronized (lock) {     \/\/ Short sleep *inside* the lock     \/\/ JDK 21: Pins carrier, making it unavailable for others' doCpuWork()     \/\/ JDK 24: Unmounts carrier, allowing it to run others' doCpuWork()     Thread.sleep(Duration.ofMillis(BLOCKING_TIME_MS)); }<\/code><\/pre>\n<ul>\n<li>\n<p><em> \u0412 Java 21 \u043a\u0430\u0436\u0434\u044b\u0439 synchronized \u0431\u043b\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u043d\u0438\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043a \u043f\u043e\u0442\u043e\u043a\u0443-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u0439.<\/em> <\/p>\n<\/li>\n<li>\n<p>\u0412 Java 24 \u0442\u0430\u043a\u0438\u0445 &#8216;\u043f\u0440\u0438\u043a\u043e\u043b\u043e\u0432&#8217; \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 <code>Thread.sleep()<\/code> \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0412\u043e\u043e\u0431\u0449\u0435 <code>Thread.sleep()<\/code> \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0430\u0440\u043a\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0438 \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438<\/h2>\n<p>\u0410 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b:<\/p>\n<pre><code>Running with Java version: 21.0.6 Launching 5,000 virtual threads... Each thread does CPU work (10,000 iterations), then acquires lock and blocks for 5 ms. All 5,000 tasks completed. Total execution time: 32.334 seconds ----------------------------------------<\/code><\/pre>\n<pre><code>Running with Java version: 24 Launching 5,000 virtual threads... Each thread does CPU work (10,000 iterations), then acquires lock and blocks for 5 ms. All 5,000 tasks completed. Total execution time: 31.592 seconds ----------------------------------------<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>-Djdk.virtualThreadScheduler.parallelism=1<\/code>. \u0425\u043e\u0442\u044f \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432\u0438\u0440\u0443\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0448\u0435\u0434\u0443\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0442\u043e\u043a\u0438-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0438, \u0442\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e \u044d\u0442\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0432\u044b\u043b\u0435\u0442\u0435\u0442\u044c.<\/p>\n<p>\u0410 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/263\/066\/edc\/263066edc8b0c27b9cb41a3e0533ab3c.png\" width=\"700\" height=\"409\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/263\/066\/edc\/263066edc8b0c27b9cb41a3e0533ab3c.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/263\/066\/edc\/263066edc8b0c27b9cb41a3e0533ab3c.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>\u0410 \u0440\u0430\u0437\u0433\u0430\u0434\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430<\/h2>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0440\u0435\u0447\u044c \u0442\u0443\u0442 \u0432 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0431\u0430\u0433\u0435. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0435 \u0440\u0430\u0437 \u043d\u0430 <code>synchronized<\/code> \u0431\u043b\u043e\u043a. \u0427\u0442\u043e \u043e\u043d \u043d\u0430\u043c \u043e\u0431\u0435\u0449\u0430\u0435\u0442? \u041e\u043d \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e <code>lock<\/code>. \u041f\u0435\u0440\u0435\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437 \u044d\u0442\u0443 \u0444\u0440\u0430\u0437\u0443 \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043f\u043e\u043b \u043c\u0438\u043d\u0443\u0442\u044b. \u041f\u043e\u0442\u043e\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e <code>lock<\/code>. \u0412\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043f\u0438\u043d\u044f\u0442\u0441\u044f \u0442\u0440\u0435\u0434\u044b \u0438\u043b\u0438 \u043d\u0435\u0442, \u043a\u0430\u0436\u0434\u044b\u0439 <code>Thread.sleep()<\/code> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e. <\/p>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e, \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0442 \u043f\u0438\u043d\u043d\u0438\u043d\u0433\u0430 \u0442\u0440\u0435\u0434\u043e\u0432 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c.<\/p>\n<h2>\u0410 \u043a\u0430\u043a \u043d\u0430\u0434\u043e?<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b <code>synchronized<\/code>, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043d\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0435. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e <code>synchronized<\/code> \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 <code>lock<\/code>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044c, \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 <strong>\u043d\u0435\u043b\u044c\u0437\u044f<\/strong>. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>synchronized<\/code> \u0431\u043b\u043e\u043a\u043e\u0432. \u041c\u044b \u0436\u0435 \u043f\u0438\u0448\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u043b\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432. <\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e, \u0437\u0430\u043c\u0435\u0440\u044f\u0435\u043c?<\/p>\n<pre><code class=\"java\">final Object lock = new Object(); \/\/ &lt;-- \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439. \u041d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043d\u0443\u0436\u0434 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430. executor.submit(() -&gt; {     try {         \/\/ This work can run concurrently if carrier threads are available.         doCpuWork();         synchronized (lock) {             \/\/ Short sleep *inside* the lock             \/\/ JDK 21: Pins carrier, making it unavailable for others' doCpuWork()             \/\/ JDK 24: Unmounts carrier, allowing it to run others' doCpuWork()             Thread.sleep(Duration.ofMillis(BLOCKING_TIME_MS));         }         completedTasks.incrementAndGet();     } catch (InterruptedException e) {         Thread.currentThread().interrupt();         System.err.println(\"Thread interrupted: \" + e.getMessage());     } catch (Exception e) {         System.err.println(\"Error in task: \" + e.getMessage());         e.printStackTrace(); \/\/ Print stack trace for unexpected errors     } });<\/code><\/pre>\n<p><strong>Java 21<\/strong><\/p>\n<pre><code>Running with Java version: 21.0.6 Launching 5,000 virtual threads... Each thread does CPU work (10,000 iterations), then acquires lock and blocks for 5 ms. All 5,000 tasks completed. Total execution time: 34.133 seconds ----------------------------------------<\/code><\/pre>\n<p>\u0421\u0442\u0430\u043b\u043e \u0434\u0430\u0436\u0435 \u0445\u0443\u0436\u0435! \u041d\u043e \u044d\u0442\u043e \u0438 \u043d\u0435 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u00a0\u2014 \u043f\u043e\u0442\u043e\u043a\u0438 \u043f\u0438\u043d\u044f\u0442\u0441\u044f \u043d\u0430 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c + \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043b\u043e\u043a\u043e\u0432. <\/p>\n<p><strong>Java 24<\/strong><\/p>\n<pre><code>Running with Java version: 24 Launching 5,000 virtual threads... Each thread does CPU work (10,000 iterations), then acquires lock and blocks for 5 ms. All 5,000 tasks completed. Total execution time: 0.640 seconds ----------------------------------------<\/code><\/pre>\n<p>\u0424\u0435\u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e! JEP \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0441\u044f.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u0414\u0430 \u043e\u0441\u043e\u0431\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u0442\u043e\u0433\u043e\u0432 \u0438 \u043d\u0435\u0442, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e JEP \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e. \u041f\u0438\u043d\u0438\u043d\u0433 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043c\u043e\u0433 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0434\u0435\u0434\u043b\u043e\u043a\u0430\u043c, \u043d\u043e \u0432 Java 24 \u0442\u0430\u043a\u043e\u0439 \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0442. \u0411\u0443\u0434\u044c\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435, \u0430 \u0432\u043e\u0442 \u0414\u0435\u043d\u0443 \u0412\u0435\u0433\u0435 \u044f \u0437\u0430\u043a\u0438\u043d\u0443\u043b <a href=\"https:\/\/github.com\/danvega\/pinning\/pull\/2\"><em>\u043f\u0443\u043b\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442<\/em><\/a>. \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/spring-aio\/java24-pinning\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a> \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430.<\/p>\n<hr\/>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6d4\/46e\/a27\/6d446ea274d27f9b546a595350de7329.png\" width=\"1560\" height=\"334\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/6d4\/46e\/a27\/6d446ea274d27f9b546a595350de7329.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6d4\/46e\/a27\/6d446ea274d27f9b546a595350de7329.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a\u00a0\u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430\u00a0Spring Boot \u0432\u00a0\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u00a0\u2014\u00a0<a href=\"https:\/\/t.me\/+oBwACbkvJ19iODAy\">Spring \u0410\u0439\u041e<\/a>, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u043c\u0438\u0440\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 Spring Boot \u0438 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0441 \u043d\u0438\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/900930\/\"> https:\/\/habr.com\/ru\/articles\/900930\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u0434\u0435\u0432\u0435\u043b\u043e\u043f\u0435\u0440 \u0430\u0434\u0432\u043e\u043a\u0430\u0442\u043e\u0432 Spring Framework, \u0414\u0435\u043d \u0412\u0435\u0433\u0430, \u043d\u0430\u00a0\u0434\u043d\u044f\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u043e\u0441\u0442 \u0432\u00a0\u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u0443\u044e \u0441\u043e\u0446\u0441\u0435\u0442\u044c, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0437\u0443\u0447\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0443 JEP 491\u00a0\u2014 Synchronize Virtual Threads without Pinning. \u0410\u0432\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u043b \u043d\u0435\u0437\u0430\u0442\u0435\u0439\u043b\u0438\u0432\u044b\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442, \u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0442 JEP \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d \u043d\u0435 \u0431\u044b\u043b. <a href=\"https:\/\/github.com\/danvega\/pinning\"><em>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/em><\/a> \u0441 \u043a\u043e\u0434\u043e\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u043b\u0441\u044f. \u0410\u0432\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u0432 \u0447\u0435\u043c \u0442\u0443\u0442 \u0434\u0435\u043b\u043e&#8230; \u0438 \u044f \u0432\u044b\u044f\u0441\u043d\u0438\u043b.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0432 \u0447\u0435\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0443\u0442\u044c JEP. \u0420\u0430\u043d\u0435\u0435, <code>synchronized<\/code> \u0431\u043b\u043e\u043a &#8216;\u043f\u0440\u0438\u0448\u0438\u0432\u0430\u043b&#8217; \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0440\u0435\u0434 \u043a \u0442\u0440\u0435\u0434\u0443 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044e. \u0418\u043d\u043e\u0433\u0434\u0430, \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u043e \u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u043e \u044d\u0442\u043e \u0431\u044b\u043b \u043e\u0434\u0438\u043d \u0438\u0437 <a href=\"https:\/\/habr.com\/ru\/companies\/spring_aio\/articles\/838912\/\">\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432<\/a> \u0432 \u043d\u0430\u0448\u0435\u043c \u0431\u043b\u043e\u0433\u0435. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Java 24 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043d\u0435\u0442 \u0438 <code>synchronized<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0440\u0435\u0434\u0430\u043c\u0438 \u0431\u0435\u0437 \u043e\u043f\u0430\u0441\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0414\u0435\u043d \u0412\u0435\u0433\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044f, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c <code>synchronized<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0435\u0434\u043e\u0432 \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0438\u0441\u0442\u043e\u0449\u0435\u043d\u0438\u0435 \u043f\u0443\u043b\u0430 \u0442\u0440\u0435\u0434\u043e\u0432-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u0439. \u041a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442, \u043a\u0430\u043a \u0442\u0440\u0438 \u043a\u043e\u043f\u0435\u0439\u043a\u0438. \u0412 \u0446\u0438\u043a\u043b\u0435 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435: <\/p>\n<p>1. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 <br \/>2. \u0414\u0435\u043b\u0430\u044e\u0442 <code>Thread.sleep()<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 <code>synchronized<\/code> \u0431\u043b\u043e\u043a\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package dev.danvega;  import java.time.Duration; import java.time.Instant; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger;  public class Application {     private static final int NUM_THREADS = 5000; \/\/ Increased threads    private static final long BLOCKING_TIME_MS = 5; \/\/ Shorter sleep inside lock    private static final int CPU_WORK_ITERATIONS = 10000; \/\/ Work *outside* lock     private static final Object lock = new Object();    private static final AtomicInteger completedTasks = new AtomicInteger(0);    private static volatile double busyWorkSink = 0; \/\/ To prevent dead code elimination     \/\/ Simple CPU-bound work    private static void doCpuWork() {       double result = 0;       for (int i = 0; i &lt; CPU_WORK_ITERATIONS; i++) {          result += Math.sin(i) * Math.cos(i);       }       \/\/ Use the result to prevent optimization       busyWorkSink += result;    }     public static void main(String[] args) throws InterruptedException {       System.out.println(\"Running with Java version: \" + System.getProperty(\"java.version\"));       System.out.printf(\"Launching %,d virtual threads...\\n\", NUM_THREADS);       System.out.printf(\"Each thread does CPU work (%,d iterations), then acquires lock and blocks for %d ms.\\n\",               CPU_WORK_ITERATIONS, BLOCKING_TIME_MS);        ThreadFactory factory = Thread.ofVirtual().factory();       try (var executor = Executors.newThreadPerTaskExecutor(factory)) {           Instant start = Instant.now();           for (int i = 0; i &lt; NUM_THREADS; i++) {             executor.submit(() -&gt; {                try {                   \/\/ This work can run concurrently if carrier threads are available.                   doCpuWork();                   synchronized (lock) {                      \/\/ Short sleep *inside* the lock                      \/\/ JDK 21: Pins carrier, making it unavailable for others' doCpuWork()                      \/\/ JDK 24: Unmounts carrier, allowing it to run others' doCpuWork()                      Thread.sleep(Duration.ofMillis(BLOCKING_TIME_MS));                   }                   completedTasks.incrementAndGet();                } catch (InterruptedException e) {                   Thread.currentThread().interrupt();                   System.err.println(\"Thread interrupted: \" + e.getMessage());                } catch (Exception e) {                   System.err.println(\"Error in task: \" + e.getMessage());                   e.printStackTrace(); \/\/ Print stack trace for unexpected errors                }             });          }           executor.shutdown();          boolean finished = executor.awaitTermination(5, TimeUnit.MINUTES);           Instant end = Instant.now();          Duration duration = Duration.between(start, end);           if (finished) {             System.out.printf(\"All %,d tasks completed.\\n\", completedTasks.get());             System.out.printf(\"Total execution time: %.3f seconds\\n\", duration.toMillis() \/ 1000.0);          } else {             System.err.printf(\"Executor timed out after 5 minutes. Tasks completed: %,d\\n\", completedTasks.get());          }       }       System.out.println(\"----------------------------------------\");       \/\/ Print sink value to ensure work wasn't optimized away       \/\/ System.out.println(\"Sink value (ignore): \" + busyWorkSink);    } }<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0427\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c<\/h2>\n<p>\u0410\u0432\u0442\u043e\u0440 \u043e\u043f\u0438\u0441\u0430\u043b \u0441\u0432\u043e\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0432\u043d\u0443\u0442\u0440\u0438 <code>synchronized<\/code> \u0431\u043b\u043e\u043a\u0430.<\/p>\n<pre><code class=\"java\">synchronized (lock) {     \/\/ Short sleep *inside* the lock     \/\/ JDK 21: Pins carrier, making it unavailable for others' doCpuWork()     \/\/ JDK 24: Unmounts carrier, allowing it to run others' doCpuWork()     Thread.sleep(Duration.ofMillis(BLOCKING_TIME_MS)); }<\/code><\/pre>\n<ul>\n<li>\n<p><em> \u0412 Java 21 \u043a\u0430\u0436\u0434\u044b\u0439 synchronized \u0431\u043b\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u043d\u0438\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043a \u043f\u043e\u0442\u043e\u043a\u0443-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u0439.<\/em> <\/p>\n<\/li>\n<li>\n<p>\u0412 Java 24 \u0442\u0430\u043a\u0438\u0445 &#8216;\u043f\u0440\u0438\u043a\u043e\u043b\u043e\u0432&#8217; \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 <code>Thread.sleep()<\/code> \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0412\u043e\u043e\u0431\u0449\u0435 <code>Thread.sleep()<\/code> \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0430\u0440\u043a\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0438 \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438<\/h2>\n<p>\u0410 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b:<\/p>\n<pre><code>Running with Java version: 21.0.6 Launching 5,000 virtual threads... Each thread does CPU work (10,000 iterations), then acquires lock and blocks for 5 ms. All 5,000 tasks completed. Total execution time: 32.334 seconds ----------------------------------------<\/code><\/pre>\n<pre><code>Running with Java version: 24 Launching 5,000 virtual threads... Each thread does CPU work (10,000 iterations), then acquires lock and blocks for 5 ms. All 5,000 tasks completed. Total execution time: 31.592 seconds ----------------------------------------<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>-Djdk.virtualThreadScheduler.parallelism=1<\/code>. \u0425\u043e\u0442\u044f \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432\u0438\u0440\u0443\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0448\u0435\u0434\u0443\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0442\u043e\u043a\u0438-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0438, \u0442\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e \u044d\u0442\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0432\u044b\u043b\u0435\u0442\u0435\u0442\u044c.<\/p>\n<p>\u0410 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>\u0410 \u0440\u0430\u0437\u0433\u0430\u0434\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430<\/h2>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0440\u0435\u0447\u044c \u0442\u0443\u0442 \u0432 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0431\u0430\u0433\u0435. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0435 \u0440\u0430\u0437 \u043d\u0430 <code>synchronized<\/code> \u0431\u043b\u043e\u043a. \u0427\u0442\u043e \u043e\u043d \u043d\u0430\u043c \u043e\u0431\u0435\u0449\u0430\u0435\u0442? \u041e\u043d \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e <code>lock<\/code>. \u041f\u0435\u0440\u0435\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437 \u044d\u0442\u0443 \u0444\u0440\u0430\u0437\u0443 \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043f\u043e\u043b \u043c\u0438\u043d\u0443\u0442\u044b. \u041f\u043e\u0442\u043e\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e <code>lock<\/code>. \u0412\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043f\u0438\u043d\u044f\u0442\u0441\u044f \u0442\u0440\u0435\u0434\u044b \u0438\u043b\u0438 \u043d\u0435\u0442, \u043a\u0430\u0436\u0434\u044b\u0439 <code>Thread.sleep()<\/code> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e. <\/p>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e, \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0442 \u043f\u0438\u043d\u043d\u0438\u043d\u0433\u0430 \u0442\u0440\u0435\u0434\u043e\u0432 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c.<\/p>\n<h2>\u0410 \u043a\u0430\u043a \u043d\u0430\u0434\u043e?<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b <code>synchronized<\/code>, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043d\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0435. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e <code>synchronized<\/code> \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 <code>lock<\/code>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044c, \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 <strong>\u043d\u0435\u043b\u044c\u0437\u044f<\/strong>. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>synchronized<\/code> \u0431\u043b\u043e\u043a\u043e\u0432. \u041c\u044b \u0436\u0435 \u043f\u0438\u0448\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u043b\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432. <\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e, \u0437\u0430\u043c\u0435\u0440\u044f\u0435\u043c?<\/p>\n<pre><code class=\"java\">final Object lock = new Object(); \/\/ &lt;-- \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439. \u041d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043d\u0443\u0436\u0434 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430. executor.submit(() -&gt; {     try {         \/\/ This work can run concurrently if carrier threads are available.         doCpuWork();         synchronized (lock) {             \/\/ Short sleep *inside* the lock             \/\/ JDK 21: Pins carrier, making it unavailable for others' doCpuWork()             \/\/ JDK 24: Unmounts carrier, allowing it to run others' doCpuWork()             Thread.sleep(Duration.ofMillis(BLOCKING_TIME_MS));         }         completedTasks.incrementAndGet();     } catch (InterruptedException e) {         Thread.currentThread().interrupt();         System.err.println(\"Thread interrupted: \" + e.getMessage());     } catch (Exception e) {         System.err.println(\"Error in task: \" + e.getMessage());         e.printStackTrace(); \/\/ Print stack trace for unexpected errors     } });<\/code><\/pre>\n<p><strong>Java 21<\/strong><\/p>\n<pre><code>Running with Java version: 21.0.6 Launching 5,000 virtual threads... Each thread does CPU work (10,000 iterations), then acquires lock and blocks for 5 ms. All 5,000 tasks completed. Total execution time: 34.133 seconds ----------------------------------------<\/code><\/pre>\n<p>\u0421\u0442\u0430\u043b\u043e \u0434\u0430\u0436\u0435 \u0445\u0443\u0436\u0435! \u041d\u043e \u044d\u0442\u043e \u0438 \u043d\u0435 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u00a0\u2014 \u043f\u043e\u0442\u043e\u043a\u0438 \u043f\u0438\u043d\u044f\u0442\u0441\u044f \u043d\u0430 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c + \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043b\u043e\u043a\u043e\u0432. <\/p>\n<p><strong>Java 24<\/strong><\/p>\n<pre><code>Running with Java version: 24 Launching 5,000 virtual threads... Each thread does CPU work (10,000 iterations), then acquires lock and blocks for 5 ms. All 5,000 tasks completed. Total execution time: 0.640 seconds ----------------------------------------<\/code><\/pre>\n<p>\u0424\u0435\u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e! JEP \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0441\u044f.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u0414\u0430 \u043e\u0441\u043e\u0431\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u0442\u043e\u0433\u043e\u0432 \u0438 \u043d\u0435\u0442, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e JEP \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e. \u041f\u0438\u043d\u0438\u043d\u0433 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043c\u043e\u0433 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0434\u0435\u0434\u043b\u043e\u043a\u0430\u043c, \u043d\u043e \u0432 Java 24 \u0442\u0430\u043a\u043e\u0439 \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0442. \u0411\u0443\u0434\u044c\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435, \u0430 \u0432\u043e\u0442 \u0414\u0435\u043d\u0443 \u0412\u0435\u0433\u0435 \u044f \u0437\u0430\u043a\u0438\u043d\u0443\u043b <a href=\"https:\/\/github.com\/danvega\/pinning\/pull\/2\"><em>\u043f\u0443\u043b\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442<\/em><\/a>. \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/spring-aio\/java24-pinning\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a> \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430.<\/p>\n<hr\/>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a\u00a0\u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430\u00a0Spring Boot \u0432\u00a0\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u00a0\u2014\u00a0<a href=\"https:\/\/t.me\/+oBwACbkvJ19iODAy\">Spring \u0410\u0439\u041e<\/a>, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u043c\u0438\u0440\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 Spring Boot \u0438 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0441 \u043d\u0438\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/900930\/\"> https:\/\/habr.com\/ru\/articles\/900930\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-457651","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/457651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=457651"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/457651\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=457651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=457651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=457651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}