TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Java

Multi-threading in Java with Examples

Overview

Multi-threading is a process of executing multiple threads in parallel. In this tutorial, we will learn about Java Threads.

What is a Thread?

A thread (sometimes also called a lightweight process) is a basic processing unit to which an OS(Operating System) allocates the processor time. The JVM(Java Virtual Machine) allows the Java application to have multiple threads running concurrently.

Each thread has a priority. Threads set with higher priority are executed before threads with lower priority.

Create a Thread

There are two ways to create a thread in Java.

  • Subclass Thread
  • Implement Runnable Interface

Thread class

One approach is to define a class to be a subclass of Thread. This subclass should override the run() method of the class Thread.

Runnable Interface

The second approach is to declare a class that implements the Runnable interface. The class can then implement the run() method. An instance of the class can then be allocated, passed as an argument when creating Thread.

—

Java Tutorials on this website:

https://www.testingdocs.com/java-tutorial/

For more information on Java, visit the official website :

https://www.oracle.com/in/java/

Related Posts

Download Greenfoot Windows

Java /

Download & Install Greenfoot on Windows

Java /

Java Static Code Analysis

Java /

Java Testing Tools

Java /

Handle Multiple Exceptions in Java

Exceptions_In_Java

Java /

Exceptions in Java Programs

› Java Strings

Recent Posts

  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • RAPTOR Editions
  • Flowgorithm Conditional Breakpoint Statement
  • Flowgorithm Read Numbers from File Example
  • Search Text File Flowchart Example
  • Flowgorithm Turtle Graphics Symbols
  • Draw Circle using Flowgorithm Turtle
  • Draw Parallel Lines using Flowgorithm Graphics

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version