Processing two tasks exactly at the same time as parallel in Java -


i want call 8 methods in method.

2 methods inside of these 8 methods 1 hole task, , remaining 6 methods hole task.

i want process these 2 tasks @ same time parallel.

as know can threads. honest either couldn't see example similar goal, or couldn't understand example if i've seen.

could briefly show me example in order me finish goal?

thanks,

somethings maybe:

import java.util.concurrent.executorservice; import java.util.concurrent.executors; import java.util.concurrent.timeunit;  public class main {     public static void main(final string[] args) throws interruptedexception {         final executorservice pool = executors.newfixedthreadpool(2);          pool.execute(() -> {             method1();             method2();         });          pool.execute(() -> {             method3();             /* ... */             method8();         });          pool.shutdown();          if (!pool.awaittermination(1, timeunit.days))             system.err.println("pool did not terminate.");     } } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -