Skip to content

This GitHub repository explores Runnable and Callable interfaces in Java. It provides examples and code implementations to demonstrate their usage in concurrent programming. Learn the differences and when to use each interface. Enhance your understanding of these Java interfaces.

Notifications You must be signed in to change notification settings

Shubh2-0/Runnable_vs._Callable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

28 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โš”๏ธ Runnable vs Callable

GitHub stars GitHub forks

Understanding Java Concurrent Interfaces

When to use Runnable vs Callable for multithreading


๐ŸŽฏ About

Explore the differences between Runnable and Callable interfaces in Java concurrent programming.

๐Ÿ“Š Comparison

Feature Runnable Callable
Return Value void V (Generic)
Exception No checked exceptions Can throw exceptions
Method run() call()
Package java.lang java.util.concurrent
Use with Thread, ExecutorService ExecutorService only

๐Ÿ’ป Examples

// Runnable - No return value
Runnable task = () -> System.out.println("Running");
new Thread(task).start();

// Callable - Returns value
Callable<Integer> task = () -> 42;
Future<Integer> future = executor.submit(task);
int result = future.get();

๐Ÿ› ๏ธ Technologies

Java | Concurrency | ExecutorService | Future

๐Ÿ“ฌ Contact

LinkedIn Gmail


Keywords: Java Runnable Callable Multithreading Concurrency Future ExecutorService

About

This GitHub repository explores Runnable and Callable interfaces in Java. It provides examples and code implementations to demonstrate their usage in concurrent programming. Learn the differences and when to use each interface. Enhance your understanding of these Java interfaces.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages