Java Concurrency & Tasks

The consensus when it comes to multithreading and concurrency in Java-land is to isolate the code you want multithreaded as a β€œtask” and send that task to some kind of executor service or thread pool.

I am wondering:

  • Could the task be any method of any object, or should it be something special (if so, what)?
  • How do you determine if this task is a processor, an IO binding, or another? What are some dead giveaways or other crucial factors?

Thanks in advance for any clarity!

+3
source share
3 answers

Take a look at ExecutorService:

  • submit(Callable)
  • submit(Runnable)

, , ( ).

, , IO, - / : IE, , , , ..

+2

Threads , , Runnable.

0

, - ( , )?

. , , , , . , . ; "Java Concurrency in Practice" Goetz et al - .

0

All Articles