设置并行流最大线程数
发表于|更新于
|浏览量:
做你自己,因为别人都有人做了。——王尔德
我们可以使用如下方式获取并行流线程数
如果我们需要更改,则可以设置系统属性:
1 | System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "8"); |
例如此处设置为8
则再次获取

可以看到是8个子线程+1个主线程,也就是9个线程
还可以使用ForkJoinPool.getCommonPoolParallelism()直接获取ForkJoinPool中允许设置的最大线程数
相关推荐
2022-03-30
lombok在生成的构造器、方法及参数上生成注解
冷眼观人,冷耳听语,冷情当感,冷心思理。——洪应明《菜根谭》 我们可以在lombok生成的构造器、方法、参数上再附带注解,参考: https://projectlombok.org/features/experimental/onX 例如下面代码: 指定构造器上新增@Autowired、@Lazy(true) getter上新增@Id、 @JsonIgnore(true) setter上新增@NonNull 1234567891011121314151617181920212223package com.ruben.simplescaffold.component;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Lazy;import org.springframework.data.annotation.Id;import org.springframework.jdbc.core.JdbcTemplate;...
2022-03-15
hutool-db
世间事,除了生死,哪一件不是闲事。——仓央嘉措《地空》 hutool操作数据库这块可以看官方文档: 这里做个简单演示:例如select * from user GAV一导 1234567891011121314151617<dependencies> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.7.22</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.28</versio...
2023-09-30
feign-reactive
晚饭少吃口,活到九十九。——钱大昕 https://github.com/openfeign/feign 目前feign不支持webflux、reactive 于是找到了一个三方库 https://github.com/kptfh/feign-reactive 基于Spring WebFlux的Reactive Feign客户端 安装: 12345678910111213141516171819202122232425262728293031323334<repositories> <repository> <id>bintray-kptfh-feign-reactive</id> <name>bintray</name> <url>https://dl.bintray.com/kptfh/feign-reactive</url> </repository></repositories>...<d...
2021-05-13
Class下的getEnumConstants
人生是一次航行。航行中必然遇到从各个方面袭来的劲风,然而每一阵风都会加快你的航速。只要你稳住航舵,即使是暴风雨,也不会使你偏离航向。 ——西·切威廉斯【美】 我们使用枚举过程中,可能会有这种需求 通过传入一个枚举的Class获取枚举里的各个常量值 其实这里有一个函数可以满足我们的需求 1java.lang.Class#getEnumConstants 在java.lang.Class类下有个函数getEnumConstants 我们可以这么使用 12345678910111213141516171819public static void main(String[] args) { LikeSelectTypeEnum[] values = getEnumValues(LikeSelectTypeEnum.class); Arrays.stream(values).forEach(System.out::println);}/** * 通过class获取枚举内的常量 * * @param type 枚举对应的class * @return T...
2020-08-10
java巨大字符串截取
string转list,分段截取 比如传入rubenrubenruben和5,得到的list就是{"ruben","ruben","ruben"}这样的 1234567891011121314151617181920/** * @param initial 初始字符串 * @param interval 分段长度 * @return */ public static List<String> stringSplit(String initial, Integer interval) { List<String> result = new LinkedList<>(); StringBuilder tmp = new StringBuilder(initial); int length = tmp.length(); while (length > 0) { ...
2020-11-27
springboot单元测试
每个圣人都有过去,每个罪人都有未来。 ――王尔德 我们在开发中经常会进行测试,如果是需要springboot环境,我们就可以使用spring-boot-starter-test 引入依赖 1234567891011<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </...

阿超
我的名字叫阿超 年龄25岁 家在北京市 职业是软件开发 每天最晚也会在八点前回家 不抽烟 酒浅尝辄止 晚上十二点上床 保证睡足八个小时 睡前写一篇博客 再做二十分钟俯卧撑暖身 然后再睡觉 基本能熟睡到天亮 像婴儿一样不留下任何疲劳和压力 就这样迎来第二天的早晨 健康检查结果也显示我很正常 我想说明我是一个不论何时都追求内心平稳的人 不拘泥于胜负 不纠结于烦恼 不树立使我夜不能寐的敌人 这就是我在这社会的生活态度
Follow Me公告
This is my Blog