Daemon Threads : Daemon Threads « Thread « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Thread » Daemon Threads 
7.4.1.Daemon Threads
class MyThread extends Thread {
  public MyThread() {
    setDaemon(true);
  }

  public void run() {

    for (int i = 1; i <= 10; i++) {
      System.out.println("Counting: " + i);
    }
  }
}

public class MainClass {
  public static void main(String[] argv) {
    MyThread ct = new MyThread();
    ct.start()
  }
}
Counting: 1
Counting: 2
Counting: 3
Counting: 4
Counting: 5
Counting: 6
Counting: 7
Counting: 8
Counting: 9
Counting: 10
7.4.Daemon Threads
7.4.1.Daemon Threads
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.