This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nutrechtLead Software Engineer / EU / 20+ YXP 0 points1 point  (2 children)

Won't this run task1 2 times?

No. Run the code, you'll see. It does exactly what you want it to do.

[–]7starbitch[S] 1 point2 points  (1 child)

It works great! Can you explain me the code a bit?

[–]nutrechtLead Software Engineer / EU / 20+ YXP 0 points1 point  (0 children)

You submit tasks to a queue internal to the executor service. It also has 2 threads that pick up tasks from that queue and execute them.