Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8
21.0
134 changes: 115 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<argLine>-Xmx1024m -Xms128m ${argLine}</argLine>
<runOrder>alphabetical</runOrder>
<!-- https://issues.apache.org/jira/browse/SUREFIRE-1731 -->
<!-- Unable to test Multi Release Jar with surefire or failsafe -->
<additionalClasspathElements>
<additionalClasspathElement>
${project.build.directory}/classes/META-INF/versions/21
</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>

Expand Down Expand Up @@ -312,25 +319,114 @@
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>

<!-- Compile code for 1.8 JVMs -->
<!-- https://maven.apache.org/plugins/maven-compiler-plugin/index.html -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<parameters>true</parameters>
<encoding>${project.build.sourceEncoding}</encoding>
<showDeprecation>true</showDeprecation>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>

</project>
<profiles>
<profile>
<id>java21</id>
<activation>
<jdk>21</jdk>
</activation>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<executions>
<execution>
<id>compile-java-8</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.8</source>
<target>1.8</target>
<parameters>true</parameters>
<encoding>${project.build.sourceEncoding}</encoding>
<showDeprecation>true</showDeprecation>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>compile-java-21</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>21</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java21</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
<parameters>true</parameters>
<encoding>${project.build.sourceEncoding}</encoding>
<showDeprecation>true</showDeprecation>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>test-java-21</id>
<phase>test</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<release>21</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/test/java21</compileSourceRoot>
</compileSourceRoots>
<parameters>true</parameters>
<encoding>${project.build.sourceEncoding}</encoding>
<showDeprecation>true</showDeprecation>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
</profile>

<profile>
<id>java8</id>
<activation>
<jdk>[1.8,21)</jdk>
</activation>

<build>
<plugins>
<!-- Compile code for 1.8 JVMs -->
<!--
https://maven.apache.org/plugins/maven-compiler-plugin/index.html -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<parameters>true</parameters>
<encoding>${project.build.sourceEncoding}</encoding>
<showDeprecation>true</showDeprecation>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
10 changes: 5 additions & 5 deletions src/main/java/com/github/thunkware/ExecutorTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;

import static com.github.thunkware.ThreadProvider.ThreadProviderFactory.threadProvider;
import static com.github.thunkware.ThreadProvider.ThreadProviderFactory.getThreadProvider;

/**
* Utility for working with Executors API from Java 21 in Java 8+
Expand All @@ -18,7 +18,7 @@ public class ExecutorTool {
* @return true if the JVM supports virtual threads
*/
public static final boolean hasVirtualThreads() {
return threadProvider.hasVirtualThreads();
return getThreadProvider().hasVirtualThreads();
}

/**
Expand All @@ -35,7 +35,7 @@ public static final boolean hasVirtualThreads() {
* @throws NullPointerException if threadFactory is null
*/
public static ExecutorService newThreadPerTaskExecutor(ThreadFactory threadFactory) {
return threadProvider.newThreadPerTaskExecutor(threadFactory);
return getThreadProvider().newThreadPerTaskExecutor(threadFactory);
}

/**
Expand All @@ -49,7 +49,7 @@ public static ExecutorService newThreadPerTaskExecutor(ThreadFactory threadFacto
* @return a new executor that creates a new virtual Thread for each task
*/
public static ExecutorService newVirtualThreadPerTaskExecutor() {
return threadProvider.newVirtualThreadPerTaskExecutor();
return getThreadProvider().newVirtualThreadPerTaskExecutor();
}

/**
Expand All @@ -59,7 +59,7 @@ public static ExecutorService newVirtualThreadPerTaskExecutor() {
* @return a new executor with limited concurrency
*/
public static ExecutorService newSempahoreVirtualExecutor(int permits) {
ExecutorService executor = threadProvider.newVirtualThreadPerTaskExecutor();
ExecutorService executor = getThreadProvider().newVirtualThreadPerTaskExecutor();
return new SempahoreExecutor(executor, permits);
}

Expand Down
Loading