mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-09-02 20:25:41 +00:00
feat[virtual thread]: upgrade java to 21 and use virtual thread
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public abstract class EventBus {
|
||||
execute(event.executorHash(), () -> doReceiver(receiver, event));
|
||||
break;
|
||||
case VirtualThread:
|
||||
logger.error("waiting for java 21 virtual thread");
|
||||
Thread.ofVirtual().name("virtual-" + clazz.getSimpleName()).start(ThreadUtils.safeRunnable(() -> doReceiver(receiver, event)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ public class MyController2 {
|
||||
|
||||
/**
|
||||
* 同一个事件可以被重复注册和接受
|
||||
*
|
||||
* 异步事件会被不会立刻执行,注意日志打印的线程号
|
||||
*/
|
||||
@EventReceiver(Bus.AsyncThread)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
||||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zfoo.event;
|
||||
|
||||
import com.zfoo.event.anno.Bus;
|
||||
import com.zfoo.event.anno.EventReceiver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author godotg
|
||||
*/
|
||||
@Component
|
||||
public class MyController3 {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MyController3.class);
|
||||
|
||||
@EventReceiver(Bus.VirtualThread)
|
||||
public void onMyNoticeEvent(MyNoticeEvent event) {
|
||||
logger.info("方法3虚拟线程执行事件:" + event.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
<!-- encoding and java version -->
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user