Skip to content

Adds a simple parallel task executor #551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 4, 2025
Merged

Adds a simple parallel task executor #551

merged 3 commits into from
Mar 4, 2025

Conversation

idlira
Copy link
Contributor

@idlira idlira commented Mar 3, 2025

Description

This is an easy to initialize and use executor which permits to run a number of limited tasks in parallel using virtual threads.
Useful for parallel tasks not demanding a complex clustered setup. For that, our framework already offers many options.

Call sample:

ParallelTaskExecutor executor = new ParallelTaskExecutor(4);

for (int i = 0; i < 1000; i++) {
    final int taskId = i;
    executor.submitTask(() -> {
        System.out.println("Executing Task " + taskId + " on thread " + Thread.currentThread().getName());
        // Enough theory, do some real stuff in here...
    });
}

executor.shutdownWhenDone();
  • tasks start running as soon as they are submitted
  • shutdown will wait until the last task finishes
  • current context is passed to each task

Additional Notes

  • This PR fixes or works on following ticket(s): OX-11751

Checklist

  • Code change has been tested and works locally
  • Code was formatted via IntelliJ and follows SonarLint & best practices
  • Patch Tasks: Is local execution of Patch Tasks necessary? If so, please also mark the PR with the tag.

@idlira idlira added the 🧬 Enhancement Contains new features label Mar 3, 2025
Fixes: OX-11751
@idlira idlira merged commit 87cc74e into develop Mar 4, 2025
3 checks passed
@idlira idlira deleted the ili/OX-11751 branch March 4, 2025 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧬 Enhancement Contains new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants