jdk
大坑大坑,踩坑记录,如果原本是jdk8的项目升级到jdk17,启动失败提示如下信息时“Exception in thread "main" java.lang.IllegalStateException: Cannot load configuration class”,“Caused by: java.lang.ExceptionInInitializerError”。启动服务时候需要添加如下信息“--add-opens java.base/java.lang=ALL-UNNAMED”。

-XX:lnitialSurvivorRatio=ratio
Sers the mla survior space rato used by the throuahpu ardae olector hicth s enabed by he -xx:-searaliecc andlor -xx:-Ra alle01 dcc odtons, Adative szino is enabledthroughput gardage olector y using the-: +searallelec and-X:+searallelldc options, and suvivor space is resized acording to the applcation behavior, starting wit the nialdisabled usng the-xx:-UseAdaptivesizeol iy optlon), hen he -xx:SrvivorRatio option shoukd be used to se he size of the survivor space for the entre executon of the aplaton
The folowig formula can be used to calculate the initiat size of survivor space (S based on the size of the young generation (Y), and the inital survivor space ratio (R)
S-Y/(R+2)
The 2in the ecuation denotes two survivor spaces. The laroer the value specfed as the initial survivor space ratio. the smaller the nitial survivor space sizey default,the initial survivor space rato is set to 8. if the default value for the young generation space size is used (2 MB), the inita size of the survivor space wil be 02 MB
The following example shows how to set the initial survivor space ratio to 4:
最近踩的坑,jdk8默认使用-XX:+UseParallelGC时候,新生代对于Eden:S1:S0的比例并不是8:1:1的,是自动分配的,有时候会导致S0与S1分配的空间特别小。




1.安全










Executors
Executor 的工厂和实用方法,ExecutorService,ScheduledExecutorService,ThreadFactory 和 Callable 类在此定义 包裹。该类支持以下几种方法:
创建和返回 ExecutorService 的方法 使用常用的配置设置进行设置。
创建和返回 ScheduledExecutorService 的方法 使用常用的配置设置进行设置。
创建并返回“包装的”ExecutorService 的方法,即 通过制定特定于实现的方法来禁用重新配置 无法访问。
创建和返回 ThreadFactory 的方法 将新创建的线程设置为已知状态。
创建和返回 Callable 的方法 脱离其他类似闭包的形式,因此可以使用它们 在需要 Callable 的执行方法中。
newFixedThreadPool
创建一个线程池,重复使用固定数量的线程 关闭共享无界队列。在任何时候,至多 nThreads 线程将是活动的处理任务。 如果在所有线程都处于活动状态时提交了额外的任务, 他们将在队列中等待,直到有线程可用。 如果任何线程在执行过程中由于失败而终止 在关闭之前,如果需要,一个新的将取代它 执行后续任务。池中的线程将存在 直到明确shutdown。

浙公网安备 33010602011771号