Skip to content

HookWoods/MultiThreading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

MultiThreading

MultiThreading is a java class to use the ExecutorService. It permits you to launch runnable async, to create repeating task or to schedule a task with a delay.

Usage

Repeating scheduler:

MultiThreading.schedule(runnable, initialDelay, interval, TimeUnit.YOURTIMES);

Delayed scheduler:

MultiThreading.schedule(runnable, delay, TimeUnit.YOURTIMES);

Async scheduler:

MultiThreading.runAsync(runnable);

Example

// Useful to repeat a Runnable with a difned amount of time
MultiThreading.schedule(() -> {
                    System.out.println("This scheduler will start after 5 seconds");
                    System.out.println("And repeat this runnable every 10 seconds.");
}, 5, 10, TimeUnit.SECONDS);

// Useful to start a runnable after a defined amount of time
MultiThreading.schedule(() -> {
            System.out.println("This scheduler will run after 5 seconds");
}, 5, TimeUnit.SECONDS);


// Useful to save file or to save data in MySQL or MongoDB
MultiThreading.runAsync(() -> { 
  if (configuration != null) persist.save(configuration);
});

                

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages