Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a Task in Java?

Java supports application to run asynchronous tasks through various mechanisms, what exactly is a task? JavaDocs: https://docs.oracle.com/javase/tutorial/essential/concurrency/index.html

like image 327
Rishabh Avatar asked Sep 07 '25 10:09

Rishabh


1 Answers

Task is just a unit of work in the abstract sense. You have tasks of some type, and then you have mechanisms to perform those tasks in an asynchronous way.

A simple example would be instances of Runnable or Callable (or even FutureTask if you want to have the name "task" in it) for the tasks, and an ExecutorService to run them.

like image 150
Kayaman Avatar answered Sep 09 '25 23:09

Kayaman