<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">What are you trying to do? I am pretty sure the current scheduler is tied directly to the implementation and if you change it, I am not surprised that things don’t work. The default scheduler creates instances of CarrierThread which has special properties. It is doubtful yours does.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 4, 2024, at 8:29 AM, 何品(虎鸣) <<a href="mailto:hepin.p@alibaba-inc.com" class="">hepin.p@alibaba-inc.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="__aliyun_email_body_block"><div style="line-height: 1.7; font-family: Tahoma, Arial, STHeiti, SimSun; font-size: 14px;" class=""><div style="clear:both;" class=""><br class=""></div><div style="clear:both;" class="">Hi, we are using Virtual threads on JDK21.0.2, and find it can stop running, all threads stopped/hung, and we can't even call thread dump.</div><div style="clear:both;" class="">We try to separate the Virtual Thread's scheduler with reflections. but that does not work too.</div><div style="clear:both;" class=""><br class=""></div><div style="clear:both;" class="">Our userbase are pretty simple:</div><div style="clear:both;" class="">A: VT Executor backing by 128-sized ThreadPoolExecutor for running java code with `CompletableFuture.get`</div><div style="clear:both;" class="">B: VT Executor backing by 64-sized ThreadPoolExecutor for retrieving data with HTTP client, with max concurrency to 3000 (virtual threads)</div><div style="clear:both;" class=""><br class=""></div><div style="clear:both;" class="">Even if A and B are using Different backing ThreadPool, they all stop responding。</div><div style="clear:both;" class=""><br class=""></div><div style="clear:both;" class=""><br class=""></div><div style="clear:both;" class=""><br class=""></div><div style="clear:both;" class="">```java</div><div style="clear:both;" class=""><div style="background-color:#1e1f22;color:#bcbec4;" class=""><pre style="font-family:'Source Code Pro',monospace;font-size:20.0px;" class="">    <span style="color:#cf8e6d;" class="">public static </span>Executor <span style="color:#56a8f5;" class="">virtualize</span><span style="color:#e8ba36;" class="">(</span><span style="color:#cf8e6d;" class="">final </span>String prefix,<br class="">                                      <span style="color:#cf8e6d;" class="">final boolean </span>enabled,<br class="">                                      <span style="color:#cf8e6d;" class="">final </span>Executor executor<span style="color:#e8ba36;" class="">) </span><span style="color:#54a857;" class="">{<br class=""></span><span style="color:#54a857;" class="">        </span><span style="color:#cf8e6d;" class="">if </span><span style="color:#e8ba36;" class="">(</span>!enabled<span style="color:#e8ba36;" class="">) </span><span style="color:#359ff4;" class="">{<br class=""></span><span style="color:#359ff4;" class="">            </span><span style="color:#cf8e6d;" class="">return </span>executor;<br class="">        <span style="color:#359ff4;" class="">}<br class=""></span><span style="color:#359ff4;" class="">        </span><span style="color:#cf8e6d;" class="">try </span><span style="color:#359ff4;" class="">{<br class=""></span><span style="color:#359ff4;" class="">            </span><span style="color:#cf8e6d;" class="">final var </span>builder = Thread.<span style="font-style:italic;" class="">ofVirtual</span><span style="color:#e8ba36;" class="">()</span>;<br class="">            <span style="color:#cf8e6d;" class="">if </span><span style="color:#e8ba36;" class="">(</span>executor != <span style="color:#cf8e6d;" class="">null</span><span style="color:#e8ba36;" class="">) </span><span style="color:#6e7ed9;" class="">{<br class=""></span><span style="color:#6e7ed9;" class="">                </span><span style="color:#cf8e6d;" class="">final var </span>clazz = builder.getClass<span style="color:#54a857;" class="">()</span>;<br class="">                <span style="color:#cf8e6d;" class="">final var </span>privateLookup = MethodHandles.<span style="font-style:italic;" class="">privateLookupIn</span><span style="color:#54a857;" class="">(</span>clazz, <span style="color:#c77dbb;font-style:italic;" class="">lookup</span><span style="color:#54a857;" class="">)</span>;<br class="">                <span style="color:#cf8e6d;" class="">final var </span>schedulerFieldSetter = privateLookup.findSetter<span style="color:#54a857;" class="">(</span>clazz, <span style="color:#6aab73;" class="">"scheduler"</span>, Executor.<span style="color:#cf8e6d;" class="">class</span><span style="color:#54a857;" class="">)</span>;<br class="">                schedulerFieldSetter.invoke<span style="color:#54a857;" class="">(</span>builder, executor<span style="color:#54a857;" class="">)</span>;<br class="">            <span style="color:#6e7ed9;" class="">}<br class=""></span><span style="color:#6e7ed9;" class="">            </span>builder.name<span style="color:#e8ba36;" class="">(</span>prefix + <span style="color:#6aab73;" class="">"-virtual-thread-"</span>, <span style="color:#2aacb8;" class="">0L</span><span style="color:#e8ba36;" class="">)</span>;<br class="">            <span style="color:#cf8e6d;" class="">final var </span>factory = builder.factory<span style="color:#e8ba36;" class="">()</span>;<br class="">            <span style="color:#cf8e6d;" class="">return </span>Executors.<span style="font-style:italic;" class="">newThreadPerTaskExecutor</span><span style="color:#e8ba36;" class="">(</span>factory<span style="color:#e8ba36;" class="">)</span>;<br class="">        <span style="color:#359ff4;" class="">} </span><span style="color:#cf8e6d;" class="">catch </span><span style="color:#e8ba36;" class="">(</span>Throwable e<span style="color:#e8ba36;" class="">) </span><span style="color:#359ff4;" class="">{<br class=""></span><span style="color:#359ff4;" class="">            </span><span style="color:#c77dbb;font-style:italic;" class="">log</span>.error<span style="color:#54a857;" class="">(</span><span style="color:#6aab73;" class="">"Error when virtualize a executor"</span>, e<span style="color:#54a857;" class="">)</span>;<br class="">            <span style="color:#cf8e6d;" class="">return </span>executor;<br class="">        <span style="color:#359ff4;" class="">}<br class=""></span><span style="color:#359ff4;" class="">    </span><span style="color:#54a857;" class="">}<br class=""></span><br class=""></pre></div></div></div></div></div></blockquote></div><br class=""></body></html>