I need a scheduler in java that shares threadpool with other schedulers

For several weeks I tried to find a solution. I come back to the same thing again and again. Java ScheduledThreadPoolExecutor alternatives ... but does nothing.

I want the tasks to be synchronized / sequentially within the scheduler, having many schedulers doing this independently, with the support of one thread ...

I have a server application in Java and I need to create hundreds and thousands of schedulers.

I want each scheduler to execute their tasks in turn and synchronize.

All schedulers can be executed simultaneously and independently, but I also need to limit the number of threads for all schedulers using threadpool (not threadpool for the scheduler, but one threadpool for ALL schedulers!). Also a great opportunity to pause / resume tasks and place them within groups. any solutions? thanks in advance!

+4
source share
7 answers

You need a lot of planners and one Contractor. Planners do not have to perform tasks themselves, but present them to the Contractor. Schedulers can be implemented as java.util.Timer tasks.

+2
source

Have you considered using HawtDispatch and many serial queues? It looks like it can do what you need with a simple API. I thought about trying it myself. The Akka project uses it, as I understand it.

+1
source

You can use the HawtDispatch thread library . It provides libdispatch api style. For your use case, you must create a sequential queue for each set of tasks that must be performed sequentially. And then plan the tasks that will be performed on them. For instance:

 DispachQueue q1 = createQueue(); DispachQueue q2 = createQueue(); ... DispachQueue qN = createQueue(); Runnable task = ... qN.execute(task) // or to execute in the future qN.dispatchAfter(1, TimeUnit.SECOND, task) 

All queues use a common thread pool.

+1
source

If you want the tasks to be executed sequentially in the ScheduledThreadPoolExecutor, you simply create an aggregated task that performs each of the real tasks in the serial fashoin and passes it to your ScheduledThreadPoolExecutor. Although, if you need thousands of schedulers to run at the same time, but still limit the number. threads, you may run into problems - at least if tasks take too long to complete, so you begin to glide along your schedule.

I would say that you should take a look at Quartz to handle this, as it will handle most of the gory planning details and assignments.

0
source

I am trying to find such a solution myself. In the .Net world, you have a common thread pool provided by a system that dynamically expands and contracts. My situation is that I have many jobs with a low level of service, one thread should be able to handle all of them.

I assume that you can use the Singleton Executor (pool with pool) somewhere and always use it to schedule tasks. This will mimic the behavior of .Net.

0
source

Perhaps a separate scheduler such as Quartz Scheduler will suit your needs?

0
source

dhtmlx scheduler works for me, but this work with its own db connection here is the source and samples of http://dhtmlx.com/docs/products/dhtmlxScheduler/index.shtml?mn and its java connector www. dhtmlx.com/x/download/regular/dhtmlxConnector_v09_java.zip

0
source

Source: https://habr.com/ru/post/1311076/


All Articles