Skip to content

saint1729/java-threads-examples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 

Repository files navigation

Java Thread Simple Examples

This repository contains more than 20 simple examples with explanations on how to use Java Thread API and Executors Framework. Currently, the following subjects are covered:

  • Running tasks from Thread and Runnable
  • Strategies for returning values from Threads and Runnable tasks
  • wait(), notify(), interrupt(), join(), isAlive()...
  • Creating Thread Pools (FixedThreadPool, CachedThreadPool, SingleThreadPool, ScheduledThreadPool...)
  • Submiting tasks to ExecutorService
  • Returning values from tasks using Callable and Future
  • Naming threads and creating deamon threads in a thread pool implementing ThreadFactory interface
  • Terminating tasks using Thread API
  • Terminating tasks using Future
  • Handling exceptions in normal threads implementing UncaughtExceptionHandler interface
  • Handling exceptions in threads on a thread pool implementing UncaughtExceptionHandler interface
  • Managing tasks termination using CountDownLatch
  • Running scheduled tasks using Timer and TimerTask
  • Running scheduled tasks using ScheduledThreadPool

Of course there are much more than this to cover (such as Fork/Join Framework). Feel free to fork this project and contribute with more simple thread examples!

About

Contains more than 20 simple examples with explanations using Thread API and Executors Framework.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%