ashishgupta_mca
ashishgupta_mca

Reputation: 578

Do invokeAll() of ExecutorService will run the task at same time or it depends totally on hardware(where executor service is running) and network

I have n independent tasks but my requirement is that all the independent task has to be executed at the same time(I want to execute at a precision of seconds means all tasks has to be invoke on the same second for e.g 11:55:05 invoke all tasks at 11 a.m 55 min 5 sec). Each task is interacting with a ngp(a hardware box) and taking a part of image rendered on a wall(here assume each ngp is generating a part of image) and therefore I need that each task interacting with ngp sends the call at the same time on the ngp through network.

When I invokeAll(), I invoke all the task(each task is interacting with its dedicated ngp and taking a part of image). Do invokeAll() of ExecutorService will try to run the task at the same time or maximum how many milliseconds delay can be there on hardware((where executor service is running)) for each task from its invoked second? Is this totally depend on hardware((where executor service is running)like CPU cores etc) and network?

I just want to grasp the hints to get the underline internal.

Upvotes: 1

Views: 805

Answers (1)

Ravindra babu
Ravindra babu

Reputation: 38910

Do invokeAll() of ExecutorService will try to run the task at the same time or maximum how many milliseconds delay can be there on hardware((where executor service is running)) for each task from its invoked second?

No. They can't run at same time. There will be delay in milli seconds. It depends on your Thread pool size too. Even if you create more threads than number of tasks, you are not guaranteed to use all threads for execution of these tasks.

Is this totally depend on hardware((where executor service is running)like CPU cores etc) and network?

It depends on number of cpu cores, your thread pool size, your task queue size and ThreadScheduler, which is specific to operating system. You can't control the timing of execution of task.

Upvotes: 1

Related Questions