xuxiaowei-com-cn opened a new issue, #8091:
URL: https://github.com/apache/incubator-seata/issues/8091

   ### Check Ahead
   
   - [x] I have searched the [issues](https://github.com/seata/seata/issues) of 
this repository and believe that this is not a duplicate.
   
   - [x] I am willing to try to implement this feature myself.
   
   
   ### Why you need it?
   
   
   **EN:**
   
   Currently, the codebase allows direct thread creation through multiple 
approaches:
   - Using `new Thread()` directly
   - Using `Executors.newXXX()` factory methods
   - Using `new ThreadPoolExecutor()` directly
   
   This inconsistency can lead to:
   1. Poor thread management and resource leaks
   2. Difficulty in monitoring and debugging thread pools
   3. Inconsistent thread naming conventions
   4. Lack of centralized thread pool configuration
   5. **Unable to leverage virtual threads**: Direct thread creation bypasses 
the centralized factory, making it impossible to globally switch to virtual 
threads for better scalability and performance
   
   To ensure better thread management and code consistency, we need to enforce 
the usage of `ThreadPoolExecutorFactory` across the entire codebase.
   
   **CN:**
   
   目前,代码库允许通过多种方式直接创建线程:
   - 直接使用 `new Thread()`
   - 使用 `Executors.newXXX()` 工厂方法
   - 直接使用 `new ThreadPoolExecutor()`
   
   这种不一致性可能导致:
   1. 线程管理不善和资源泄漏
   2. 难以监控和调试线程池
   3. 线程命名约定不一致
   4. 缺乏集中的线程池配置
   5. **无法利用虚拟线程**:直接创建线程会绕过集中式工厂,导致无法全局切换到虚拟线程以获得更好的可扩展性和性能
   
   为了确保更好的线程管理和代码一致性,我们需要在整个代码库中强制使用 `ThreadPoolExecutorFactory`。
   
   ### How it could be?
   
   _No response_
   
   ### Other related information
   
   
   **EN:**
   
   **Benefits:**
   - Centralized thread pool management
   - Better resource control and monitoring
   - Consistent thread naming across the project
   - Easier debugging and troubleshooting
   - **Support for virtual threads**: `ThreadPoolExecutorFactory` provides 
built-in support for virtual threads (Project Loom), allowing global switching 
between platform threads and virtual threads without code changes
   - Future-proof architecture ready for Java 21+ virtual thread features
   
   **Affected areas:**
   - Production code: Must use `ThreadPoolExecutorFactory`
   - Test code: Allowed to use direct thread creation for testing purposes
   - Config packages (`org.apache.seata.config`, `io.seata.config`): Allowed 
exceptions
   
   **CN:**
   
   **优势:**
   - 集中的线程池管理
   - 更好的资源控制和监控
   - 项目中一致的线程命名
   - 更容易的调试和故障排除
   - **支持虚拟线程**:`ThreadPoolExecutorFactory` 内置支持虚拟线程(Project 
Loom),允许在平台线程和虚拟线程之间全局切换,无需修改代码
   - 面向未来的架构,为 Java 21+ 虚拟线程特性做好准备
   
   **影响范围:**
   - 生产代码:必须使用 `ThreadPoolExecutorFactory`
   - 测试代码:允许使用直接线程创建进行测试
   - Config 包(`org.apache.seata.config`、`io.seata.config`):允许例外


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to