Skip to content

Put threads in a pool and execute a given number of tasks at same time

License

Notifications You must be signed in to change notification settings

gmrodrigues/TaskPooler

Repository files navigation

TaskPooler

Put threads in a pool and execute a given number of tasks at same time

        TaskPool taskPool = new TaskPool(2); //Create a task pool with capacity or running 2 tasks at same time
        try {
            taskPool.runTask(task1); // run task1 runnable
            taskPool.runTask(task2); // run task2 runnable
            taskPool.runTask(task3); // run task3 runnable
            taskPool.runTask(task4); // run task4 runnable
            taskPool.waitAllTaskToFinish(); // wait until all tasks finish
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }
        

About

Put threads in a pool and execute a given number of tasks at same time

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages