File tree Expand file tree Collapse file tree
java/com/litongjava/tio/http/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 <name >${project.artifactId} </name >
99 <properties >
1010 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
11- <java .version>1.8 </java .version>
11+ <java .version>21 </java .version>
1212 <maven .compiler.source>${java.version} </maven .compiler.source>
1313 <maven .compiler.target>${java.version} </maven .compiler.target>
14- <tio-boot .version>2.0.5</tio-boot .version>
15-
16-
14+ <tio-boot .version>2.0.6</tio-boot .version>
1715 <main .class>com.litongjava.tio.http.server.MainApp</main .class>
1816 </properties >
1917 <dependencies >
2624 <dependency >
2725 <groupId >com.litongjava</groupId >
2826 <artifactId >java-db</artifactId >
29- <version >1.5.5 </version >
27+ <version >1.5.6 </version >
3028 </dependency >
3129
30+
3231 <dependency >
3332 <groupId >ch.qos.logback</groupId >
3433 <artifactId >logback-classic</artifactId >
35- <version >1.2.13 </version >
34+ <version >1.3.3 </version >
3635 </dependency >
3736
3837 <dependency >
Original file line number Diff line number Diff line change 11package com .litongjava .tio .http .server ;
22
3+ import java .lang .Thread .Builder .OfVirtual ;
4+ import java .util .concurrent .ExecutorService ;
5+ import java .util .concurrent .Executors ;
6+ import java .util .concurrent .ThreadFactory ;
7+
38import com .litongjava .tio .boot .TioApplication ;
9+ import com .litongjava .tio .boot .server .TioBootServer ;
410import com .litongjava .tio .http .server .config .MainAppConfig ;
511
612public class MainApp {
713
814 public static void main (String [] args ) {
915 long start = System .currentTimeMillis ();
16+
17+ // 1. 虚拟线程工厂(用于 work 线程)
18+ OfVirtual ofVirtual = Thread .ofVirtual ();
19+ ThreadFactory workTf = ofVirtual .name ("t-io-v-" , 1 ).factory ();
20+
21+ // 2. 设置 readWorkers 使用的线程工厂
22+ TioBootServer server = TioBootServer .me ();
23+ server .setWorkThreadFactory (workTf );
24+
25+ // 3. 创建业务虚拟线程 Executor(每任务一个虚拟线程)
26+ ThreadFactory bizTf = Thread .ofVirtual ().name ("t-biz-v-" , 0 ).factory ();
27+
28+ ExecutorService bizExecutor = Executors .newThreadPerTaskExecutor (bizTf );
29+
30+ server .setBizExecutor (bizExecutor );
31+
1032 TioApplication .run (MainApp .class , new MainAppConfig (), args );
1133 long end = System .currentTimeMillis ();
1234 System .out .println ((end - start ) + "ms" );
Original file line number Diff line number Diff line change 11http.response.header.showServer =true
22server.port =8080
3+ server.protocol =http
34# JDBC_URL=jdbc:mysql://192.168.3.9/hello_world?useSSL=false&allowPublicKeyRetrieval=true
45# JDBC_USER=root
56# JDBC_PSWD=robot_123456#
You can’t perform that action at this time.
0 commit comments