Java Threads

Sharon Watkins
2 min readApr 6, 2021

--

Threads allows a program to operate more efficiently by doing multiple things at the same time. Threads can be used to perform complicated tasks in the background without interrupting the main program. Threads are sometimes called lightweight processes. Both processes and threads provide an execution environment, but creating a new thread requires fewer resources than creating a new process.

Threads exist within a process — every process has at least one. Threads share the process’s resources, including memory and open files. This makes for efficient, but potentially problematic, communication.

Multithreaded execution is an essential feature of the Java platform. Every application has at least one thread — or several, if you count “system” threads that do things like memory management and signal handling. But from the application programmer’s point of view, you start with just one thread, called the main thread. This thread has the ability to create additional threads, as we’ll demonstrate in the next section.

Why are Java Threads important?…

They make our application faster. They allow use to do multiple things at the same time.

Practical use cases for Java Threads….

  • In Computer Games, whether they are first person games or multiplayer games, threads come to the rescue.
  • Asynchronous communication can allow an application to perform additional tasks instead of waiting for tasks to complete.
  • Applications that have a number of tasks that can be performed in any order can often benefit from distributed asynchronous communication.

Learn more about threads with Oracle documentation.

--

--

Sharon Watkins
Sharon Watkins

Written by Sharon Watkins

Just a Mom With ADD who enjoys Code

No responses yet