Runnable
The functional interface for a task that takes no input and returns no result, used to give a thread work to do.
In more detail
Its single method is run. A lambda such as () -> System.out.println("work") is a Runnable. When a task must return a value or throw a checked exception, use Callable instead.
Related terms
- thread — A path of execution inside a process that the operating system schedules on a processor; one process can have many.
- Callable — The functional interface for a task that returns a result and may throw an exception, submitted to an executor.
- functional interface — An interface with exactly one abstract method, such as Runnable, Supplier or Predicate, which a lambda or method reference can implement.
Taught in
- Concurrency Basics: Threads And Runnable — Modern Java: Virtual Threads & High-Throughput Services
- Objects, Nested Classes And Garbage Collection — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Jars, Automatic Modules And Runtime Images — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Platform And Virtual Threads, Runnable And Callable — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Modules And Concurrency — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Mock Exam: Sit It, Score It — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep