Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java multi thread

// Java code for thread creation by extending
// the Thread class
class MultithreadingDemo extends Thread {
    public void run()
    {
        try {
            // Displaying the thread that is running
            System.out.println(
                "Thread " + Thread.currentThread().getId()
                + " is running");
        }
        catch (Exception e) {
            // Throwing an exception
            System.out.println("Exception is caught");
        }
    }
}
 
// Main Class
public class Multithread {
    public static void main(String[] args)
    {
        int n = 8; // Number of threads
        for (int i = 0; i < n; i++) {
            MultithreadingDemo object
                = new MultithreadingDemo();
            object.start();
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: Alerter for java 
Java :: precision java 
Java :: java switch tutorial 
Java :: java infinity 
Java :: json java 
Java :: what is stringbuilder used for in java 
Java :: input arraylist in java 
Java :: java stream index 
Java :: streams in java 
Java :: how to close scanner in java 
Java :: java collectors mapping 
Java :: what is jar file in java 
Java :: positive numbers in array 
Java :: How to solve the knapsack problem, in Java? 
Java :: java.sql.SQLSyntaxErrorException: Unknown column 
Java :: how to declare a interface in java 
Java :: method 
Java :: how to return an object in java 
Java :: java put() method 
Java :: Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. 
Java :: String to java.sql.Date 
Java :: androi amterila inpout dialgue to get inouti diaogue 
Java :: md5 java ee 
Java :: connect as SYSDBA java 
Java :: strictfp java example 
Java :: full screen in libgdx Lwjgl3 
Java :: exchangerate api 
Java :: make new file in intellij for java 
Java :: cfgbcfdxv 
Java :: set integer array value to null java 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =