CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades

Threads

Threads
Introduction
How threads work

How threads work

  • A thread is a single sequential flow of control within a program. A thread often completes a specific task.
  • By default, a Java application uses a single thread, called the main thread.
  • However, some programs can benefit by using two or more threads to allow different parts of the program to execute simultaneously.
  • On a computer that has just one central processing unit, or CPU, the threads don't actually execute simultaneously. Instead, a part of the Java virtual machine called the thread scheduler alternately lets portions of each thread execute.
  • This gives the appearance that all of the tasks are running at the same time. And it can make an application work more efficiently.

Previous | Concepts | How threads work | Typical uses for threads | Classes and interfaces | Life cycle | Next