Multithreading in Java
page 2 of 5
by Debjani Mallick
Average Rating: 
Views (Total / Last 10 Days): 24173/ 43

Main Thread

It is the entry point from where the execution begins. Every Java program contains at least one thread which is called the main thread. It is the entry point from where the execution begins and from the main thread, we can start other threads. By default there is a main thread existing in every Java program.

Listing 1

class threadDemo
  public static void main(String a[])
    Thread t = Thread.currentThread();
    System.out.println("Current Thread: " + t);
    System.out.println("After changing the name, the thread is " + t);
    for (int i = 5; i > 0; i--)
      System.out.println("Current Thread: " + i);

While doing a multithreading program, the main thread should terminate only after all the other threads get terminated.

View Entire Article

User Comments

Title: good   
Name: sathyaraj
Date: 2008-07-01 4:52:18 AM
we learn more about multithreading .............
Title: Thread program not working   
Name: Thread program not working
Date: 2008-04-30 6:25:37 AM
Listing 1
Thread program not working
Title: Very Nice   
Name: Ajit
Date: 2007-08-20 3:20:09 AM
Keep Up
Title: Nice   
Name: Jonas
Date: 2007-08-15 10:48:08 AM
Its a good piece of writing
Title: Good   
Name: Rocky
Date: 2007-08-14 10:37:54 PM
Keep up the good work

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-06-15 3:55:33 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search