Jay Roy
asked on
ExecutorService v/s ScheduledExService
hi
i was reading through ExecutorService v/s ScheduledExecutorService
In what scenario do i use ExecutorService and in what scenarios do i use
ScheduledExecutorService ?
Can anyone give a simple example?
Can i create a pool of threads and use it with scheduledExecutorService?
thanks
i was reading through ExecutorService v/s ScheduledExecutorService
In what scenario do i use ExecutorService and in what scenarios do i use
ScheduledExecutorService ?
Can anyone give a simple example?
Can i create a pool of threads and use it with scheduledExecutorService?
thanks
And ExecutorService, will run them immediately only if there are threads available in its pool.
Else, it will wait for the threads to become free.
Else, it will wait for the threads to become free.
>>Can i create a pool of threads and use it with scheduledExecutorService?
Only if you want have tasks to run with some delay. Otherwise I dont see a need.
Only if you want have tasks to run with some delay. Otherwise I dont see a need.
ASKER
ok, let me give specific example, if i have 80 update queries to execute is it a good practice to use
ExecutorService (feeding task to a pool of threads) or do i use ScheduledExecutorService and run the tasks every microsecond ?
Which one will be more faster and better design?
thanks
ExecutorService (feeding task to a pool of threads) or do i use ScheduledExecutorService and run the tasks every microsecond ?
Which one will be more faster and better design?
thanks
As I said, unless there is a specific reason I will not go for ScheduledExecutorService.
Executor Service should suffice your requirement.
As I said in your last question, make each task, to use its own hibernate session.
Executor Service should suffice your requirement.
As I said in your last question, make each task, to use its own hibernate session.
ASKER
>>>When you want to schedule the task after certain delay or some period, you should use ScheduledExecutorService.
can you provide an example(real world)?
thanks.
can you provide an example(real world)?
thanks.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
ok makes sense, thanks
ASKER
ScheduledExecutorService ?
When you want to schedule the task after certain delay or some period, you should use ScheduledExecutorService.
And if you want to run them immediately, then use Executor Service.