Java Thread

Concurrency

  • Concurrency

    • Logical

    • Single Core / Multi Core

  • Parallel

    • Physical

    • Multi Core

Since Java runs on the JVM (Java Virtual Machine), you don't need to worry about the physical aspects!

What is a Java Thread?

  • Process

    : A program that operates independently (Eclipse, Messenger, etc)

  • Thread

    : A small unit of execution that constitutes a Process (Messenger = chat + file transfer)

  • Multi-process

    : Running multiple processes simultaneously

  • Multi-thread

    : Multiple threads operating simultaneously within a single process

Creating a Java Thread

Method 1) Implementing the Runnable interface

  • Runnable interface

    ex)

  • Test

Method 2) Extending the Thread class

  • Thread class

    ex)

package virus;

public class CoronaThread extends Thread{ int num;

}

Memory Structure When Running a Thread

Last updated