{"id":480765,"date":"2026-05-23T15:26:06","date_gmt":"2026-05-23T15:26:06","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=480765"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=480765","title":{"rendered":"\u0427\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0441 Project Loom? \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438 \u043a\u043e\u0434"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/1037932\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b \u0442\u0435\u043e\u0440\u0438\u044e Project Loom: virtual threads, Scoped Values \u0438 preview Structured Concurrency. \u0422\u0430\u043c \u0431\u044b\u043b\u0430 \u043e\u0431\u0449\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430: \u0437\u0430\u0447\u0435\u043c Loom \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f, \u043f\u043e\u0447\u0435\u043c\u0443 virtual threads \u043d\u0435 \u0443\u0441\u043a\u043e\u0440\u044f\u044e\u0442 \u043b\u044e\u0431\u043e\u0439 \u043a\u043e\u0434, \u0447\u0435\u043c <code>ScopedValue<\/code> \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 <code>ThreadLocal<\/code>, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b <code>Joiner<\/code> \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 Structured Concurrency \u0432\u0441\u0435 \u0435\u0449\u0435 preview.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/61\/36\/3b\/61363ba2e80f4f88804e56c621482e32.jpg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/61\/36\/3b\/61363ba2e80f4f88804e56c621482e32.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/61\/36\/3b\/61363ba2e80f4f88804e56c621482e32.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0435\u043e\u0440\u0438\u0438 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430:<\/p>\n<ol>\n<li>\n<p>\u041a\u0430\u043a \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c preview Structured Concurrency.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a\u0438\u0435 \u0444\u043b\u0430\u0433\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f <code>javac<\/code>, Maven \u0438 Gradle.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 <code>ScopedValue<\/code> \u0434\u043b\u044f request context.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <code>StructuredTaskScope<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>allSuccessfulOrThrow()<\/code> \u0438 <code>anySuccessfulOrThrow()<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0437\u0430\u0434\u0430\u0442\u044c timeout \u043d\u0430 \u0432\u0435\u0441\u044c scope.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a <code>ScopedValue<\/code> \u0438 <code>StructuredTaskScope<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432\u043c\u0435\u0441\u0442\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e preview-\u043b\u0438\u043d\u0438\u044e JDK 25+. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 GA-\u0440\u0435\u043b\u0438\u0437 &#8212; Java 26. \u0422\u0435\u043a\u0443\u0449\u0438\u0439 LTS-\u0440\u0435\u043b\u0438\u0437 &#8212; Java 25. JDK 27 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043a\u0430\u043a early access \u0438 \u043d\u0435\u0441\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0443\u044e preview-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e Structured Concurrency. API \u043c\u0435\u0436\u0434\u0443 preview-\u0440\u0435\u043b\u0438\u0437\u0430\u043c\u0438 \u0435\u0449\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u0440\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u0441\u043d\u0438\u043f\u043f\u0435\u0442\u044b \u0438\u0437 incubator \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u043b\u0435\u043f\u0443\u044e &#8212; \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 JDK.<\/p>\n<p>\u041f\u043e\u0433\u043d\u0430\u043b\u0438.<\/p>\n<hr\/>\n<h3>8. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 preview<\/h3>\n<p>Virtual threads \u0441 Java 21 \u0443\u0436\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 preview-\u0444\u043b\u0430\u0433\u043e\u0432:<\/p>\n<pre><code class=\"bash\">javac Main.javajava Main<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>ScopedValue<\/code> \u0441 JDK 25 \u0442\u043e\u0436\u0435 final. \u0415\u0441\u043b\u0438 \u0432\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043d\u0438\u043c, preview-\u0444\u043b\u0430\u0433\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b.<\/p>\n<p>\u0410 \u0432\u043e\u0442 Structured Concurrency \u043f\u043e\u043a\u0430 preview. \u0417\u043d\u0430\u0447\u0438\u0442, \u043d\u0443\u0436\u043d\u044b \u0444\u043b\u0430\u0433\u0438 \u0438 \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438 \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0435.<\/p>\n<p>\u0414\u043b\u044f JDK 27 EA \u0441 JEP 533:<\/p>\n<pre><code class=\"bash\">javac --enable-preview --release 27 Main.javajava --enable-preview Main<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f JDK 26:<\/p>\n<pre><code class=\"bash\">javac --enable-preview --release 26 Main.javajava --enable-preview Main<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u044f \u0431\u044b \u043d\u0430\u0447\u0430\u043b \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0438 <code>javac<\/code>. \u041c\u0435\u043d\u044c\u0448\u0435 \u043c\u0430\u0433\u0438\u0438 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430, \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u0433\u0434\u0435 \u043e\u0448\u0438\u0431\u043a\u0430: \u0432 \u043a\u043e\u0434\u0435, \u0432\u0435\u0440\u0441\u0438\u0438 JDK \u0438\u043b\u0438 \u0444\u043b\u0430\u0433\u0430\u0445.<\/p>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"java\">import java.util.concurrent.StructuredTaskScope;public class Main {    public static void main(String[] args) throws Exception {        try (var scope = StructuredTaskScope.open()) {            var hello = scope.fork(() -&gt; \"Hello\");            var loom = scope.fork(() -&gt; \"Loom\");            scope.join();            System.out.println(hello.get() + \", \" + loom.get());        }    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0434\u043b\u044f JDK 27 EA:<\/p>\n<pre><code class=\"bash\">javac --enable-preview --release 27 Main.javajava --enable-preview Main<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0431\u044b\u0442\u044c <code>--enable-preview<\/code>, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0447\u0435\u0441\u0442\u043d\u043e \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442, \u0447\u0442\u043e \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 preview API. \u041d\u0438\u0447\u0435\u0433\u043e \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e.<\/p>\n<hr\/>\n<h3>9. Maven<\/h3>\n<p>\u0414\u043b\u044f Maven \u043d\u0443\u0436\u043d\u044b \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438: compiler plugin \u0438 surefire, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<pre><code class=\"xml\">&lt;plugin&gt;    &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;    &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;    &lt;configuration&gt;        &lt;release&gt;27&lt;\/release&gt;        &lt;compilerArgs&gt;            &lt;arg&gt;--enable-preview&lt;\/arg&gt;        &lt;\/compilerArgs&gt;    &lt;\/configuration&gt;&lt;\/plugin&gt;&lt;plugin&gt;    &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;    &lt;artifactId&gt;maven-surefire-plugin&lt;\/artifactId&gt;    &lt;configuration&gt;        &lt;argLine&gt;--enable-preview&lt;\/argLine&gt;    &lt;\/configuration&gt;&lt;\/plugin&gt;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>&lt;argLine&gt;<\/code> \u0434\u043b\u044f JaCoCo \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u0432, \u043d\u0435 \u043d\u0430\u0434\u043e \u0435\u0433\u043e \u043c\u043e\u043b\u0447\u0430 \u0437\u0430\u0442\u0438\u0440\u0430\u0442\u044c. \u0418\u043d\u0430\u0447\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0435 preview-\u0444\u043b\u0430\u0433, \u0430 coverage agent \u043f\u0440\u043e\u043f\u0430\u0434\u0435\u0442 &#8212; \u0438 CI \u043d\u0430\u0447\u043d\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u043e.<\/p>\n<p>\u0412 \u0436\u0438\u0432\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u0431\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043d\u0435\u0441 \u044d\u0442\u043e \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u044c:<\/p>\n<pre><code class=\"xml\">&lt;profiles&gt;    &lt;profile&gt;        &lt;id&gt;loom-preview&lt;\/id&gt;        &lt;build&gt;            &lt;plugins&gt;                &lt;plugin&gt;                    &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;                    &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;                    &lt;configuration&gt;                        &lt;release&gt;27&lt;\/release&gt;                        &lt;compilerArgs&gt;                            &lt;arg&gt;--enable-preview&lt;\/arg&gt;                        &lt;\/compilerArgs&gt;                    &lt;\/configuration&gt;                &lt;\/plugin&gt;                &lt;plugin&gt;                    &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;                    &lt;artifactId&gt;maven-surefire-plugin&lt;\/artifactId&gt;                    &lt;configuration&gt;                        &lt;argLine&gt;--enable-preview&lt;\/argLine&gt;                    &lt;\/configuration&gt;                &lt;\/plugin&gt;            &lt;\/plugins&gt;        &lt;\/build&gt;    &lt;\/profile&gt;&lt;\/profiles&gt;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a:<\/p>\n<pre><code class=\"bash\">mvn -Ploom-preview test<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a \u043f\u0440\u043e\u0449\u0435 \u043d\u0435 \u043f\u0440\u043e\u0442\u0430\u0449\u0438\u0442\u044c preview \u0432 \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 pet project, \u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 CI \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438.<\/p>\n<hr\/>\n<h3>10. Gradle<\/h3>\n<p>\u0414\u043b\u044f Gradle \u0438\u0434\u0435\u044f \u0442\u0430 \u0436\u0435: toolchain \u043f\u043b\u044e\u0441 preview-\u0444\u043b\u0430\u0433\u0438 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0442\u0435\u0441\u0442\u043e\u0432 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430.<\/p>\n<pre><code>java {    toolchain {        languageVersion = JavaLanguageVersion.of(27)    }}tasks.withType(JavaCompile).configureEach {    options.compilerArgs += \"--enable-preview\"}tasks.withType(Test).configureEach {    jvmArgs += \"--enable-preview\"}tasks.withType(JavaExec).configureEach {    jvmArgs += \"--enable-preview\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Kotlin DSL:<\/p>\n<pre><code class=\"kotlin\">java {    toolchain {        languageVersion.set(JavaLanguageVersion.of(27))    }}tasks.withType&lt;JavaCompile&gt;().configureEach {    options.compilerArgs.add(\"--enable-preview\")}tasks.withType&lt;Test&gt;().configureEach {    jvmArgs(\"--enable-preview\")}tasks.withType&lt;JavaExec&gt;().configureEach {    jvmArgs(\"--enable-preview\")}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u0435\u0441\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u043d\u043e \u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u043f\u0440\u043e preview features, \u0437\u043d\u0430\u0447\u0438\u0442 \u0444\u043b\u0430\u0433 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e. \u0422\u0430\u043a\u043e\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0438 runtime &#8212; \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430.<\/p>\n<hr\/>\n<h3>11. Scoped Values: request context \u0431\u0435\u0437 ThreadLocal<\/h3>\n<p>\u0422\u0435\u043e\u0440\u0438\u044e <code>ScopedValue<\/code> \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0417\u0434\u0435\u0441\u044c &#8212; \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u043c \u043a\u043e\u0434\u0435. \u0424\u0438\u0447\u0430 \u0443\u0436\u0435 final \u0441 JDK 25, preview-\u0444\u043b\u0430\u0433\u0438 \u0434\u043b\u044f \u043d\u0435\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u0435\u0441\u0442\u044c request context:<\/p>\n<pre><code class=\"java\">public record RequestContext(        String requestId,        String tenantId,        String userId) {}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u043b\u044f scoped value:<\/p>\n<pre><code class=\"java\">import java.lang.ScopedValue;public final class RequestContextHolder {    public static final ScopedValue&lt;RequestContext&gt; REQUEST =            ScopedValue.newInstance();    private RequestContextHolder() {    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Endpoint \u0438\u043b\u0438 handler \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">import static com.example.RequestContextHolder.REQUEST;public Response handle(Request request) throws Exception {    var context = new RequestContext(            request.id(),            request.tenantId(),            request.userId()    );    return ScopedValue            .where(REQUEST, context)            .call(() -&gt; service.handle(request));}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0438\u0436\u0435 \u043f\u043e \u0441\u0442\u0435\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442:<\/p>\n<pre><code class=\"java\">import static com.example.RequestContextHolder.REQUEST;public List&lt;Order&gt; loadOrders(String userId) {    RequestContext context = REQUEST.get();    log.info(\"load orders, requestId={}, tenant={}\",            context.requestId(),            context.tenantId());    return orderClient.load(context.tenantId(), userId);}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0427\u0442\u043e \u0432\u0430\u0436\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 <code>call()<\/code> binding \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043d\u0443\u0436\u0435\u043d <code>finally { remove(); }<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>REQUEST.get()<\/code> \u0432\u043d\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0443\u043d\u043a\u0442 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u041b\u0443\u0447\u0448\u0435 \u0443\u043f\u0430\u0441\u0442\u044c \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439, \u0447\u0435\u043c \u043f\u043e\u0442\u043e\u043c \u043b\u043e\u0432\u0438\u0442\u044c \u0432 \u043b\u043e\u0433\u0430\u0445 \u201c\u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435\u201d \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u0432.<\/p>\n<p>\u041d\u043e <code>ScopedValue<\/code> \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0437\u0434\u0435. \u0415\u0441\u043b\u0438 <code>tenantId<\/code> \u043d\u0443\u0436\u0435\u043d \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0435 \u043c\u0435\u0442\u043e\u0434\u0430, \u043b\u0443\u0447\u0448\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c:<\/p>\n<pre><code class=\"java\">orderClient.loadRecent(tenantId, userId);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438, security context \u0438 \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u0432\u0435\u0449\u0435\u0439, <code>ScopedValue<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0445\u043e\u0440\u043e\u0448\u043e.<\/p>\n<hr\/>\n<h3>12. \u041f\u0435\u0440\u0432\u044b\u0439 StructuredTaskScope: \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c Structured Concurrency &#8212; \u0442\u0430 \u0441\u0430\u043c\u0430\u044f preview-\u0447\u0430\u0441\u0442\u044c Loom, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u043d\u0443\u0436\u043d\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<pre><code class=\"java\">import java.util.List;import java.util.concurrent.StructuredTaskScope;import java.util.concurrent.StructuredTaskScope.Subtask;public UserPage loadUserPage(String userId) throws Exception {    try (var scope = StructuredTaskScope.open()) {        Subtask&lt;User&gt; user =                scope.fork(() -&gt; userClient.load(userId));        Subtask&lt;List&lt;Order&gt;&gt; orders =                scope.fork(() -&gt; orderClient.loadRecent(userId));        Subtask&lt;List&lt;Recommendation&gt;&gt; recommendations =                scope.fork(() -&gt; recommendationClient.loadFor(userId));        scope.join();        return new UserPage(                user.get(),                orders.get(),                recommendations.get()        );    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<ul>\n<li>\n<p>\u0432\u0441\u0435 \u0442\u0440\u0438 \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 \u043e\u0434\u043d\u043e\u043c\u0443 scope;<\/p>\n<\/li>\n<li>\n<p>\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u044f\u0432\u043d\u043e \u0436\u0434\u0435\u0442 \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 <code>join()<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u043b\u0435 <code>join()<\/code> \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0447\u0435\u0440\u0435\u0437 <code>Subtask.get()<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u0433\u0434\u0430 scope \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0431\u043b\u043e\u043a\u0430, \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0441\u0445\u043e\u0437\u043d\u044b\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0411\u0435\u0437 structured scope \u044f \u0431\u044b \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u0435\u0440\u0436\u0430\u043b \u0432 \u0433\u043e\u043b\u043e\u0432\u0435: \u201c\u0430 \u0447\u0442\u043e \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 future, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u0443\u043f\u0430\u043b\u0430?\u201d. \u0421\u043e scope \u044d\u0442\u0430 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: \u043d\u0435 \u043d\u0430\u0434\u043e \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c <code>Subtask<\/code> \u043d\u0430\u0440\u0443\u0436\u0443 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e. \u041f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 scope, \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u043c \u0436\u0435, \u0434\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f scope.<\/p>\n<hr\/>\n<h3>13. \u0412\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430: allSuccessfulOrThrow()<\/h3>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u044d\u0442\u043e\u0442 joiner \u0432 \u0442\u0435\u043e\u0440\u0438\u0438. \u0417\u0434\u0435\u0441\u044c &#8212; \u043f\u043e\u043b\u043d\u044b\u0439 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u044b\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0443\u0436\u043d\u043e \u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u0443\u0441\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<pre><code class=\"java\">import java.util.List;import java.util.concurrent.StructuredTaskScope;import java.util.concurrent.StructuredTaskScope.Joiner;public List&lt;String&gt; loadFragments(String documentId) throws Exception {    try (var scope = StructuredTaskScope.open(            Joiner.&lt;String&gt;allSuccessfulOrThrow())) {        scope.fork(() -&gt; fragmentClient.load(documentId, \"header\"));        scope.fork(() -&gt; fragmentClient.load(documentId, \"body\"));        scope.fork(() -&gt; fragmentClient.load(documentId, \"footer\"));        return scope.join();    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c <code>join()<\/code> \u0441\u0430\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 joiner\u2019\u0430. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0438\u0441\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>List&lt;String&gt;<\/code>. \u0415\u0441\u043b\u0438 \u043e\u0434\u043d\u0430 \u0443\u043f\u0430\u043b\u0430, scope \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u0430 <code>join()<\/code> \u0431\u0440\u043e\u0441\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0445\u043e\u0440\u043e\u0448\u043e \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \u201c\u0438\u043b\u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0432\u0441\u0435, \u0438\u043b\u0438 \u0432\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0435\u0443\u0441\u043f\u0435\u0448\u043d\u0430\u201d.<\/p>\n<p>\u041d\u043e \u044f \u0431\u044b \u043d\u0435 \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043d\u0430\u0442\u044f\u043d\u0443\u0442\u044c \u044d\u0442\u043e\u0442 joiner \u043d\u0430 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438. \u0415\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043a\u0430\u043a \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 <code>User<\/code>, <code>Order<\/code> \u0438 <code>Recommendation<\/code>, \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 <code>Subtask&lt;T&gt;<\/code>. \u0418 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. Structured Concurrency \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c Java \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 DSL.<\/p>\n<hr\/>\n<h3>14. \u041f\u0435\u0440\u0432\u044b\u0439 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442: anySuccessfulOrThrow()<\/h3>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 joiner \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0427\u0430\u0441\u0442\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439: \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0435\u0440\u043a\u0430\u043b, \u0440\u0435\u043f\u043b\u0438\u043a \u0438\u043b\u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432, \u0438 \u043d\u0430\u0441 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<pre><code class=\"java\">import java.util.concurrent.StructuredTaskScope;import java.util.concurrent.StructuredTaskScope.Joiner;public Price loadPrice(String sku) throws Exception {    try (var scope = StructuredTaskScope.open(            Joiner.&lt;Price&gt;anySuccessfulOrThrow())) {        scope.fork(() -&gt; priceClientA.load(sku));        scope.fork(() -&gt; priceClientB.load(sku));        scope.fork(() -&gt; priceClientC.load(sku));        return scope.join();    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u043d\u044f\u0442\u044c. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u0443\u043f\u0430\u043b\u0438, <code>join()<\/code> \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0440\u043e\u043c \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b\u043e\u0441\u044c \u0432 \u0441\u0430\u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0433\u043e\u043d\u043a\u0438 \u043d\u0430 <code>CompletableFuture.anyOf()<\/code>, \u0440\u0443\u0447\u043d\u044b\u0435 <code>cancel()<\/code>, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0433\u0438\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u0442\u0438\u043f\u043e\u0432. \u0417\u0434\u0435\u0441\u044c \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0430 \u043f\u0440\u044f\u043c\u043e: <code>anySuccessfulOrThrow()<\/code>.<\/p>\n<p>\u0422\u0443\u0442 \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442\u043c\u0435\u043d\u044b. \u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u0436\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u0442\u043c\u0435\u043d\u0430 Java-\u043f\u043e\u0442\u043e\u043a\u0430 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u043c\u0435\u043d\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435. \u042d\u0442\u043e \u043d\u0435 \u043c\u0438\u043d\u0443\u0441 Structured Concurrency, \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c. Timeout \u0438 cancellation \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0447\u0435\u0442\u0430\u0442\u044c\u0441\u044f \u0441 timeout\u2019\u0430\u043c\u0438 HTTP-\u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0411\u0414 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432.<\/p>\n<hr\/>\n<h3>15. Timeout \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c scope<\/h3>\n<p>Timeout &#8212; \u044d\u0442\u043e \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0438\u0434\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043e\u0442 \u201c\u044f \u0433\u0434\u0435-\u0442\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0442\u0430\u0439\u043c\u0435\u0440\u201d.<\/p>\n<pre><code class=\"java\">import java.time.Duration;import java.util.concurrent.StructuredTaskScope;import java.util.concurrent.StructuredTaskScope.Joiner;public SearchResult search(String query) throws Exception {    try (var scope = StructuredTaskScope.open(            Joiner.&lt;SearchResult&gt;anySuccessfulOrThrow(),            cfg -&gt; cfg                    .withName(\"search\")                    .withTimeout(Duration.ofMillis(300)))) {        scope.fork(() -&gt; searchClientA.search(query));        scope.fork(() -&gt; searchClientB.search(query));        scope.fork(() -&gt; searchClientC.search(query));        return scope.join();    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 timeout \u0438\u0441\u0442\u0435\u043a, scope \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u0432\u0441\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u0433\u0440\u0443\u043f\u043f\u0443. \u042d\u0442\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0443\u0436\u0435 \u0432\u0435\u0440\u043d\u0443\u043b \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0430 \u0442\u0440\u0438 HTTP-\u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0433\u0434\u0435-\u0442\u043e \u0434\u043e\u0431\u0438\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<p>\u0414\u043b\u044f backend \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435: \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 timeout.<\/p>\n<p>\u041d\u043e \u0442\u0443\u0442 \u0442\u043e\u0436\u0435 \u0431\u0435\u0437 \u0438\u043b\u043b\u044e\u0437\u0438\u0439. Timeout scope \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>timeout HTTP-\u043a\u043b\u0438\u0435\u043d\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>timeout \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414;<\/p>\n<\/li>\n<li>\n<p>\u043b\u0438\u043c\u0438\u0442 connection pool;<\/p>\n<\/li>\n<li>\n<p>circuit breaker;<\/p>\n<\/li>\n<li>\n<p>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 <code>InterruptedException<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>Structured Concurrency \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u0433\u0440\u0443\u043f\u043f\u044b \u0437\u0430\u0434\u0430\u0447. \u041d\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u044d\u0442\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/p>\n<hr\/>\n<h3>16. Scoped Values \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e StructuredTaskScope<\/h3>\n<p>Virtual threads, Scoped Values \u0438 Structured Concurrency \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b\u0438 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0417\u0434\u0435\u0441\u044c &#8212; \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0445 \u0441\u0432\u044f\u0437\u043a\u0438. \u0414\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 <code>StructuredTaskScope<\/code>, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 scoped values \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, endpoint \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. \u041c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c <code>RequestContext<\/code> \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0440\u0443\u043a\u0430\u043c\u0438, \u043d\u043e \u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0433\u0438\u044e \u0441 <code>ThreadLocal<\/code> \u0442\u0430\u0449\u0438\u0442\u044c \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f.<\/p>\n<pre><code class=\"java\">import java.lang.ScopedValue;import java.util.List;import java.util.concurrent.StructuredTaskScope;import java.util.concurrent.StructuredTaskScope.Subtask;public final class UserPageService {    private static final ScopedValue&lt;RequestContext&gt; REQUEST =            ScopedValue.newInstance();    public UserPage handle(Request request) throws Exception {        var context = new RequestContext(                request.id(),                request.tenantId(),                request.userId()        );        return ScopedValue                .where(REQUEST, context)                .call(() -&gt; loadUserPage(request.userId()));    }    private UserPage loadUserPage(String userId) throws Exception {        try (var scope = StructuredTaskScope.open()) {            Subtask&lt;User&gt; user =                    scope.fork(() -&gt; loadUser(userId));            Subtask&lt;List&lt;Order&gt;&gt; orders =                    scope.fork(() -&gt; loadOrders(userId));            Subtask&lt;List&lt;Recommendation&gt;&gt; recommendations =                    scope.fork(() -&gt; loadRecommendations(userId));            scope.join();            return new UserPage(                    user.get(),                    orders.get(),                    recommendations.get()            );        }    }    private User loadUser(String userId) {        RequestContext context = REQUEST.get();        return userClient.load(context.tenantId(), userId);    }    private List&lt;Order&gt; loadOrders(String userId) {        RequestContext context = REQUEST.get();        return orderClient.loadRecent(context.tenantId(), userId);    }    private List&lt;Recommendation&gt; loadRecommendations(String userId) {        RequestContext context = REQUEST.get();        return recommendationClient.loadFor(context.tenantId(), userId);    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0443\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0436\u0438\u0432\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441. \u041f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u0438\u0434\u044f\u0442 \u0442\u043e\u0442 \u0436\u0435 <code>tenantId<\/code> \u0438 <code>requestId<\/code>, \u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043f\u0440\u0430\u0432\u0430 \u043c\u0435\u043d\u044f\u0442\u044c binding. \u041a\u043e\u0433\u0434\u0430 <code>handle()<\/code> \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442.<\/p>\n<p><code>StructuredTaskScope<\/code> \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u0430 <code>ScopedValue<\/code> \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0421 <code>ThreadLocal<\/code> \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0447\u0435\u0440\u0435\u0437 <code>remove()<\/code>. \u0417\u0434\u0435\u0441\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0432\u0438\u0434\u043d\u0430 \u043f\u0440\u044f\u043c\u043e \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<hr\/>\n<h3>17. \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b<\/h3>\n<p>\u042f \u0431\u044b \u043d\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u0441 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u041b\u0443\u0447\u0448\u0435 \u0432\u0437\u044f\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439: \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e downstream-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0438\u0441\u043a \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430, \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 endpoint.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043b\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043b\u0438 \u0445\u0432\u043e\u0441\u0442\u044b \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0447\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043b\u043e\u0433\u0438 \u0438 thread dump;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u043b\u0438 \u0432\u044b backpressure \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0441 fixed pool \u043d\u0430 virtual threads;<\/p>\n<\/li>\n<li>\n<p>\u0433\u0434\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0436\u0438\u0442\u044c timeout\u2019\u044b: \u043d\u0430 scope, HTTP-\u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u0411\u0414, gateway.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e. Preview API \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443: \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 preview-\u0432\u0435\u0440\u0441\u0438\u0438 \u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c. \u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435: \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 JDK, \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442, \u043f\u043e\u0435\u0445\u0430\u043b\u0438 \u0434\u0430\u043b\u044c\u0448\u0435. \u0412 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u043c API preview-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c \u0434\u043e\u043b\u0433\u043e\u043c.<\/p>\n<p>Structured Concurrency \u0441\u0435\u0439\u0447\u0430\u0441 \u043b\u0443\u0447\u0448\u0435 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445: \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445 \u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 JEP.<\/p>\n<hr\/>\n<h3>18. \u0427\u0430\u0441\u0442\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438<\/h3>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430: \u0437\u0430\u0431\u044b\u043b\u0438 <code>--enable-preview<\/code> \u043d\u0430 runtime. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u043f\u0440\u043e\u0448\u043b\u0430, \u0442\u0435\u0441\u0442\u044b \u0438\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u043a \u0443\u043f\u0430\u043b\u0438. \u041b\u0435\u0447\u0438\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u043b\u0430\u0433\u0430 \u0432 <code>Test<\/code>, <code>JavaExec<\/code>, surefire \u0438\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>java<\/code>.<\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f: \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u043b\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 JDK \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0437 \u0441\u0442\u0430\u0440\u044b\u0445 preview. \u0423 Structured Concurrency API \u043c\u0435\u043d\u044f\u043b\u0441\u044f. \u041a\u043e\u0434 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434 JDK 21 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0441\u0442\u044c \u0441 JDK 25, 26 \u0438\u043b\u0438 27.<\/p>\n<p>\u0422\u0440\u0435\u0442\u044c\u044f: \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e virtual threads \u0441\u0430\u043c\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 backpressure. \u041d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u044b\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 50 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u0430\u0434\u043e \u044f\u0432\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c.<\/p>\n<p>\u0427\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f: \u043f\u043e\u043b\u043e\u0436\u0438\u043b\u0438 \u0432 <code>ScopedValue<\/code> mutable map \u201c\u043d\u0430 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0436\u0438\u0437\u043d\u0438\u201d. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u0442\u0430\u0440\u044b\u0439 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043d\u043e\u0432\u043e\u0439 \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0435.<\/p>\n<p>\u041f\u044f\u0442\u0430\u044f: \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e cancel \u0432 Java \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u043c \u043c\u0438\u0440\u0435. \u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0430, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u0442. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u043a\u043b\u0438\u0435\u043d\u0442, \u0434\u0440\u0430\u0439\u0432\u0435\u0440, \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0438 timeout\u2019\u044b.<\/p>\n<hr\/>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 Project Loom \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>virtual threads \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0437 preview-\u0444\u043b\u0430\u0433\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p><code>ScopedValue<\/code> \u0441 JDK 25 \u0442\u043e\u0436\u0435 final;<\/p>\n<\/li>\n<li>\n<p>Structured Concurrency \u0432\u0441\u0435 \u0435\u0449\u0435 preview, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 <code>--enable-preview<\/code> \u0438 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u0438 \u0441 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 JDK.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c\u0430\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u043a\u0430 \u0434\u043b\u044f backend-\u043a\u043e\u0434\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a: \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 bounded context \u0447\u0435\u0440\u0435\u0437 <code>ScopedValue<\/code>, \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f <code>StructuredTaskScope<\/code>, \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>Structured Concurrency \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435: \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432\u0438\u0434\u043d\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0442\u043e\u0447\u043a\u0443 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435. \u041f\u043e\u0441\u043b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438\u043b\u0438 timeout \u043d\u0435 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043b\u0438\u0448\u043d\u0438\u0435 \u0444\u043e\u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<hr\/>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0431\u043b\u0438\u0437\u043a\u0438 \u0442\u0435\u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u0441\u0442\u0430\u0440\u0442\u0430\u043f\u043e\u0432, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0430\u0441 \u0432 \u043c\u043e\u0451\u043c <a href=\"https:\/\/t.me\/tech_lead_rst\" rel=\"noopener noreferrer nofollow\">\u0431\u043b\u043e\u0433\u0435<\/a>.<\/p>\n<hr\/>\n<p>\u041b\u0435\u0433\u043a\u0438\u0445 \u0412\u0430\u043c \u0420\u0435\u043b\u0438\u0437\u043e\u0432!<\/p>\n<\/div>\n<p>\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\/1038528\/\">https:\/\/habr.com\/ru\/articles\/1038528\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b \u0442\u0435\u043e\u0440\u0438\u044e Project Loom: virtual threads, Scoped Values \u0438 preview Structured Concurrency. \u0422\u0430\u043c \u0431\u044b\u043b\u0430 \u043e\u0431\u0449\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430: \u0437\u0430\u0447\u0435\u043c Loom \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f, \u043f\u043e\u0447\u0435\u043c\u0443 virtual threads \u043d\u0435 \u0443\u0441\u043a\u043e\u0440\u044f\u044e\u0442 \u043b\u044e\u0431\u043e\u0439 \u043a\u043e\u0434, \u0447\u0435\u043c ScopedValue \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 ThreadLocal, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b Joiner \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 Structured Concurrency \u0432\u0441\u0435 \u0435\u0449\u0435 preview.\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430.\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0435\u043e\u0440\u0438\u0438 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430:\u041a\u0430\u043a \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c preview Structured Concurrency.\u041a\u0430\u043a\u0438\u0435 \u0444\u043b\u0430\u0433\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f javac, Maven \u0438 Gradle.\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 ScopedValue \u0434\u043b\u044f request context.\u041a\u0430\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 StructuredTaskScope.\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c allSuccessfulOrThrow() \u0438 anySuccessfulOrThrow().\u041a\u0430\u043a \u0437\u0430\u0434\u0430\u0442\u044c timeout \u043d\u0430 \u0432\u0435\u0441\u044c scope.\u041a\u0430\u043a ScopedValue \u0438 StructuredTaskScope \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432\u043c\u0435\u0441\u0442\u0435.\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e preview-\u043b\u0438\u043d\u0438\u044e JDK 25+. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 GA-\u0440\u0435\u043b\u0438\u0437 &#8212; Java 26. \u0422\u0435\u043a\u0443\u0449\u0438\u0439 LTS-\u0440\u0435\u043b\u0438\u0437 &#8212; Java 25. JDK 27 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043a\u0430\u043a early access \u0438 \u043d\u0435\u0441\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0443\u044e preview-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e Structured Concurrency. API \u043c\u0435\u0436\u0434\u0443 preview-\u0440\u0435\u043b\u0438\u0437\u0430\u043c\u0438 \u0435\u0449\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u0440\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u0441\u043d\u0438\u043f\u043f\u0435\u0442\u044b \u0438\u0437 incubator \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u043b\u0435\u043f\u0443\u044e &#8212; \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 JDK.\u041f\u043e\u0433\u043d\u0430\u043b\u0438.8. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 previewVirtual threads \u0441 Java 21 \u0443\u0436\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 preview-\u0444\u043b\u0430\u0433\u043e\u0432:javac Main.javajava MainScopedValue \u0441 JDK 25 \u0442\u043e\u0436\u0435 final. \u0415\u0441\u043b\u0438 \u0432\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043d\u0438\u043c, preview-\u0444\u043b\u0430\u0433\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b.\u0410 \u0432\u043e\u0442 Structured Concurrency \u043f\u043e\u043a\u0430 preview. \u0417\u043d\u0430\u0447\u0438\u0442, \u043d\u0443\u0436\u043d\u044b \u0444\u043b\u0430\u0433\u0438 \u0438 \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438 \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0435.\u0414\u043b\u044f JDK 27 EA \u0441 JEP 533:javac &#8212;enable-preview &#8212;release 27 Main.javajava &#8212;enable-preview Main\u0414\u043b\u044f JDK 26:javac &#8212;enable-preview &#8212;release 26 Main.javajava &#8212;enable-preview Main\u0414\u043b\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u044f \u0431\u044b \u043d\u0430\u0447\u0430\u043b \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0438 javac. \u041c\u0435\u043d\u044c\u0448\u0435 \u043c\u0430\u0433\u0438\u0438 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430, \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u0433\u0434\u0435 \u043e\u0448\u0438\u0431\u043a\u0430: \u0432 \u043a\u043e\u0434\u0435, \u0432\u0435\u0440\u0441\u0438\u0438 JDK \u0438\u043b\u0438 \u0444\u043b\u0430\u0433\u0430\u0445.\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:import java.util.concurrent.StructuredTaskScope;public class Main {    public static void main(String[] args) throws Exception {        try (var scope = StructuredTaskScope.open()) {            var hello = scope.fork(() -&gt; &#171;Hello&#187;);            var loom = scope.fork(() -&gt; &#171;Loom&#187;);            scope.join();            System.out.println(hello.get() + &#171;, &#187; + loom.get());        }    }}\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0434\u043b\u044f JDK 27 EA:javac &#8212;enable-preview &#8212;release 27 Main.javajava &#8212;enable-preview Main\u0415\u0441\u043b\u0438 \u0437\u0430\u0431\u044b\u0442\u044c &#8212;enable-preview, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0447\u0435\u0441\u0442\u043d\u043e \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442, \u0447\u0442\u043e \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 preview API. \u041d\u0438\u0447\u0435\u0433\u043e \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e.9. Maven\u0414\u043b\u044f Maven \u043d\u0443\u0436\u043d\u044b \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438: compiler plugin \u0438 surefire, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u0442\u0435\u0441\u0442\u044b.&lt;plugin&gt;    &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;    &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;    &lt;configuration&gt;        &lt;release&gt;27&lt;\/release&gt;        &lt;compilerArgs&gt;            &lt;arg&gt;&#8212;enable-preview&lt;\/arg&gt;        &lt;\/compilerArgs&gt;    &lt;\/configuration&gt;&lt;\/plugin&gt;&lt;plugin&gt;    &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;    &lt;artifactId&gt;maven-surefire-plugin&lt;\/artifactId&gt;    &lt;configuration&gt;        &lt;argLine&gt;&#8212;enable-preview&lt;\/argLine&gt;    &lt;\/configuration&gt;&lt;\/plugin&gt;\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 &lt;argLine&gt; \u0434\u043b\u044f JaCoCo \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u0432, \u043d\u0435 \u043d\u0430\u0434\u043e \u0435\u0433\u043e \u043c\u043e\u043b\u0447\u0430 \u0437\u0430\u0442\u0438\u0440\u0430\u0442\u044c. \u0418\u043d\u0430\u0447\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0435 preview-\u0444\u043b\u0430\u0433, \u0430 coverage agent \u043f\u0440\u043e\u043f\u0430\u0434\u0435\u0442 &#8212; \u0438 CI \u043d\u0430\u0447\u043d\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u043e.\u0412 \u0436\u0438\u0432\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u0431\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043d\u0435\u0441 \u044d\u0442\u043e \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u044c:&lt;profiles&gt;    &lt;profile&gt;        &lt;id&gt;loom-preview&lt;\/id&gt;        &lt;build&gt;            &lt;plugins&gt;                &lt;plugin&gt;                    &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;                    &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;                    &lt;configuration&gt;                        &lt;release&gt;27&lt;\/release&gt;                        &lt;compilerArgs&gt;                            &lt;arg&gt;&#8212;enable-preview&lt;\/arg&gt;                        &lt;\/compilerArgs&gt;                    &lt;\/configuration&gt;                &lt;\/plugin&gt;                &lt;plugin&gt;                    &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;                    &lt;artifactId&gt;maven-surefire-plugin&lt;\/artifactId&gt;                    &lt;configuration&gt;                        &lt;argLine&gt;&#8212;enable-preview&lt;\/argLine&gt;                    &lt;\/configuration&gt;                &lt;\/plugin&gt;            &lt;\/plugins&gt;        &lt;\/build&gt;    &lt;\/profile&gt;&lt;\/profiles&gt;\u0417\u0430\u043f\u0443\u0441\u043a:mvn -Ploom-preview test\u0422\u0430\u043a \u043f\u0440\u043e\u0449\u0435 \u043d\u0435 \u043f\u0440\u043e\u0442\u0430\u0449\u0438\u0442\u044c preview \u0432 \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 pet project, \u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 CI \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438.10. Gradle\u0414\u043b\u044f Gradle \u0438\u0434\u0435\u044f \u0442\u0430 \u0436\u0435: toolchain \u043f\u043b\u044e\u0441 preview-\u0444\u043b\u0430\u0433\u0438 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0442\u0435\u0441\u0442\u043e\u0432 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430.java {    toolchain {        languageVersion = JavaLanguageVersion.of(27)    }}tasks.withType(JavaCompile).configureEach {    options.compilerArgs += &#171;&#8212;enable-preview&#187;}tasks.withType(Test).configureEach {    jvmArgs += &#171;&#8212;enable-preview&#187;}tasks.withType(JavaExec).configureEach {    jvmArgs += &#171;&#8212;enable-preview&#187;}\u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Kotlin DSL:java {    toolchain {        languageVersion.set(JavaLanguageVersion.of(27))    }}tasks.withType&lt;JavaCompile&gt;().configureEach {    options.compilerArgs.add(&#171;&#8212;enable-preview&#187;)}tasks.withType&lt;Test&gt;().configureEach {    jvmArgs(&#171;&#8212;enable-preview&#187;)}tasks.withType&lt;JavaExec&gt;().configureEach {    jvmArgs(&#171;&#8212;enable-preview&#187;)}\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u0435\u0441\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u043d\u043e \u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u043f\u0440\u043e preview features, \u0437\u043d\u0430\u0447\u0438\u0442 \u0444\u043b\u0430\u0433 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e. \u0422\u0430\u043a\u043e\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0438 runtime &#8212; \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430.11. Scoped Values: request context \u0431\u0435\u0437 ThreadLocal\u0422\u0435\u043e\u0440\u0438\u044e ScopedValue \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0417\u0434\u0435\u0441\u044c &#8212; \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u043c \u043a\u043e\u0434\u0435. \u0424\u0438\u0447\u0430 \u0443\u0436\u0435 final \u0441 JDK 25, preview-\u0444\u043b\u0430\u0433\u0438 \u0434\u043b\u044f \u043d\u0435\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b.\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u0435\u0441\u0442\u044c request context:public record RequestContext(        String requestId,        String tenantId,        String userId) {}\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u043b\u044f scoped value:import java.lang.ScopedValue;public final class RequestContextHolder {    public static final ScopedValue&lt;RequestContext&gt; REQUEST =            ScopedValue.newInstance();    private RequestContextHolder() {    }}Endpoint \u0438\u043b\u0438 handler \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:import static com.example.RequestContextHolder.REQUEST;public Response handle(Request request) throws Exception {    var context = new RequestContext(            request.id(),            request.tenantId(),            request.userId()    );    return ScopedValue            .where(REQUEST, context)            .call(() -&gt; service.handle(request));}\u041d\u0438\u0436\u0435 \u043f\u043e \u0441\u0442\u0435\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442:import static com.example.RequestContextHolder.REQUEST;public List&lt;Order&gt; loadOrders(String userId) {    RequestContext context = REQUEST.get();    log.info(&#171;load orders, requestId={}, tenant={}&#187;,            context.requestId(),            context.tenantId());    return orderClient.load(context.tenantId(), userId);}\u0427\u0442\u043e \u0432\u0430\u0436\u043d\u043e:\u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 call() binding \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442;\u043d\u0435 \u043d\u0443\u0436\u0435\u043d finally { remove(); };\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438;\u0435\u0441\u043b\u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c REQUEST.get() \u0432\u043d\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430.\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0443\u043d\u043a\u0442 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u041b\u0443\u0447\u0448\u0435 \u0443\u043f\u0430\u0441\u0442\u044c \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439, \u0447\u0435\u043c \u043f\u043e\u0442\u043e\u043c \u043b\u043e\u0432\u0438\u0442\u044c \u0432 \u043b\u043e\u0433\u0430\u0445 \u201c\u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435\u201d \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u0432.\u041d\u043e ScopedValue \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0437\u0434\u0435. \u0415\u0441\u043b\u0438 tenantId \u043d\u0443\u0436\u0435\u043d \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0435 \u043c\u0435\u0442\u043e\u0434\u0430, \u043b\u0443\u0447\u0448\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c:orderClient.loadRecent(tenantId, userId);\u0410 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438, security context \u0438 \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u0432\u0435\u0449\u0435\u0439, ScopedValue \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0445\u043e\u0440\u043e\u0448\u043e.12. \u041f\u0435\u0440\u0432\u044b\u0439 StructuredTaskScope: \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0422\u0435\u043f\u0435\u0440\u044c Structured Concurrency &#8212; \u0442\u0430 \u0441\u0430\u043c\u0430\u044f preview-\u0447\u0430\u0441\u0442\u044c Loom, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.\u0421\u0430\u043c\u044b\u0439 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u043d\u0443\u0436\u043d\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.import java.util.List;import java.util.concurrent.StructuredTaskScope;import java.util.concurrent.StructuredTaskScope.Subtask;public UserPage loadUserPage(String userId) throws Exception {    try (var scope = StructuredTaskScope.open()) {        Subtask&lt;User&gt; user =                scope.fork(() -&gt; userClient.load(userId));        Subtask&lt;List&lt;Order&gt;&gt; orders =                scope.fork(() -&gt; orderClient.loadRecent(userId));        Subtask&lt;List&lt;Recommendation&gt;&gt; recommendations =                scope.fork(() -&gt; recommendationClient.loadFor(userId));        scope.join();        return new UserPage(                user.get(),                orders.get(),                recommendations.get()        );    }}\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435:\u0432\u0441\u0435 \u0442\u0440\u0438 \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 \u043e\u0434\u043d\u043e\u043c\u0443 scope;\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u044f\u0432\u043d\u043e \u0436\u0434\u0435\u0442 \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 join();\u043f\u043e\u0441\u043b\u0435 join() \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0447\u0435\u0440\u0435\u0437 Subtask.get();\u043a\u043e\u0433\u0434\u0430 scope \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0431\u043b\u043e\u043a\u0430, \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0441\u0445\u043e\u0437\u043d\u044b\u043c\u0438.\u0411\u0435\u0437 structured scope \u044f \u0431\u044b \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u0435\u0440\u0436\u0430\u043b \u0432 \u0433\u043e\u043b\u043e\u0432\u0435: \u201c\u0430 \u0447\u0442\u043e \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 future, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u0443\u043f\u0430\u043b\u0430?\u201d. \u0421\u043e scope \u044d\u0442\u0430 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: \u043d\u0435 \u043d\u0430\u0434\u043e \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c Subtask \u043d\u0430\u0440\u0443\u0436\u0443 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e. \u041f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 scope, \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u043c \u0436\u0435, \u0434\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f scope.13. \u0412\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430: allSuccessfulOrThrow()\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u044d\u0442\u043e\u0442 joiner \u0432 \u0442\u0435\u043e\u0440\u0438\u0438. \u0417\u0434\u0435\u0441\u044c &#8212; \u043f\u043e\u043b\u043d\u044b\u0439 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440.\u0418\u043d\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u044b\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0443\u0436\u043d\u043e \u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u0443\u0441\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430.import java.util.List;import java.util.concurrent.StructuredTaskScope;import java.util.concurrent.StructuredTaskScope.Joiner;public List&lt;String&gt; loadFragments(String documentId) throws Exception {    try (var scope = StructuredTaskScope.open(            Joiner.&lt;String&gt;allSuccessfulOrThrow())) {        scope.fork(() -&gt; fragmentClient.load(documentId, &#171;header&#187;));        scope.fork(() -&gt; fragmentClient.load(documentId, &#171;body&#187;));        scope.fork(() -&gt; fragmentClient.load(documentId, &#171;footer&#187;));        return scope.join();    }}\u0417\u0434\u0435\u0441\u044c join() \u0441\u0430\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 joiner\u2019\u0430. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-480765","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/480765","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=480765"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/480765\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=480765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=480765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=480765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}