Skip to content

Commit

Permalink
Updates for some port allocations and scheduled always to single thre…
Browse files Browse the repository at this point in the history
…aded execution
  • Loading branch information
GedMarc committed May 12, 2024
1 parent fb582ce commit d1ad4c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void destroy()
*/
private static int getJavaVersion()
{
String version = getSystemPropertyOrEnvironment("java.version", "11");
String version = getSystemPropertyOrEnvironment("java.version", "21");
if (version.startsWith("1."))
{
version = version.substring(2);
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/com/guicedee/guicedinjection/JobService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ public class JobService implements IGuicePreDestroy<JobService>, IJobService
private static TimeUnit defaultWaitUnit = TimeUnit.SECONDS;

public static final JobService INSTANCE = new JobService();
private static ExecutorService jobCleanup = null;


private static final ThreadFactory factory = Thread.ofVirtual().factory();

static
{
jobCleanup = INSTANCE.jobCleanup();
INSTANCE.jobCleanup();
}

public JobService()
Expand Down Expand Up @@ -302,9 +303,7 @@ public ScheduledExecutorService addPollingJob(String jobPoolName, Runnable threa
.isShutdown())
{
registerJobPollingPool(jobPoolName,
Executors.newScheduledThreadPool(Runtime
.getRuntime()
.availableProcessors()));
Executors.newSingleThreadScheduledExecutor(factory));
}
ScheduledExecutorService service = pollingMap.get(jobPoolName);
service.scheduleAtFixedRate(thread, 1L, delay, unit);
Expand All @@ -320,18 +319,18 @@ public ScheduledExecutorService addPollingJob(String jobPoolName, Runnable threa
@Override
public ScheduledExecutorService addPollingJob(String jobPoolName, Runnable thread, long initialDelay, long delay, TimeUnit unit)
{
ScheduledExecutorService scheduledExecutorService = null;
if (!pollingMap.containsKey(jobPoolName) || pollingMap
.get(jobPoolName)
.isTerminated() || pollingMap
.get(jobPoolName)
.isShutdown())
{
registerJobPollingPool(jobPoolName,
Executors.newSingleThreadScheduledExecutor());
scheduledExecutorService = registerJobPollingPool(jobPoolName,
Executors.newSingleThreadScheduledExecutor());
}
ScheduledExecutorService service = pollingMap.get(jobPoolName);
service.scheduleAtFixedRate(thread, initialDelay, delay, unit);
return service;
scheduledExecutorService.scheduleAtFixedRate(thread, initialDelay, delay, unit);
return scheduledExecutorService;
}

/**
Expand Down

0 comments on commit d1ad4c4

Please sign in to comment.