All Projects → jorgeacetozi → java-threads-examples

jorgeacetozi / java-threads-examples

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

Programming Languages

java
68154 projects - #9 most used programming language

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!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].