File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package demo ;
2+
3+ import org .noear .solon .annotation .Managed ;
4+ import org .noear .solon .core .bean .LifecycleBean ;
5+ import org .noear .solon .core .util .ThreadsUtil ;
6+
7+ /**
8+ *
9+ * @author noear 2026/1/5 created
10+ *
11+ */
12+ @ Managed
13+ public class VirtualCom implements LifecycleBean {
14+ @ Override
15+ public void start () throws Throwable {
16+ try {
17+ ThreadsUtil .newVirtualThreadPerTaskExecutor ().submit (() -> {
18+ System .out .println ("a: " + Thread .currentThread ().getName ());
19+ });
20+
21+ ThreadsUtil .newVirtualThreadPerTaskExecutor ("test-v1-" ).submit (() -> {
22+ System .out .println ("b: " + Thread .currentThread ().getName ());
23+ });
24+
25+
26+ ThreadsUtil .newVirtualThreadFactory ().newThread (() -> {
27+ System .out .println ("c: " + Thread .currentThread ().getName ());
28+ }).start ();
29+
30+ ThreadsUtil .newVirtualThreadFactory ("test-v2-" ).newThread (() -> {
31+ System .out .println ("d: " + Thread .currentThread ().getName ());
32+ }).start ();
33+ } catch (Throwable e ) {
34+ e .printStackTrace ();
35+ }
36+
37+ Thread .sleep (1000 );
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments