'Back-End/Java_1'에 해당되는 글 48건

donaricano-btn

Daemon Thread

- Daemon Thread is a service provider thread that provides services to the user thread

- Its life depend on the mercy of user thread i.e. all the user threads dies, JVM terminates this thread automatically

- gc, finalizer etc..


1. Points to remember for Daemon Thread

- It provides services to user threads for background supporting tasks

- Its life depends on user thread

- It is a low priority thread

2. Why JVM terminates the daemon thread if there is no user thread?

- The sole purpose of the daemon thread is that it provides services to user thread for background supporting task

- If there is no user thread, we don't need daemon threads

3. Methods for Daemon thread by Thread class

1) public void setDaemon(boolean status)

- It is used to mark the current thread as daemon thread or user thread

2) public boolean isDaemon()

- It is used to check that current is daemon

4. Example



'Back-End > Java_1' 카테고리의 다른 글

[Java] Shutdown Hook  (0) 2016.10.10
[Java] Thread pool  (0) 2016.10.10
[Java] Thread Priority  (0) 2016.10.07
[Java] Naming Thread  (0) 2016.10.07
[Java] Joining a thread  (0) 2016.10.07
블로그 이미지

리딩리드

,
donaricano-btn

Thread Priority

- Each thread have a priority

- Thread schedular schedules the threads according to their priority(preemptive scheduling)


1. 3 constants defined in Thread

- public static int MIN_PRIORITY

- public static int NORM-PRIORITY

- public static int MAX-PRIORITY

- Default is 5(NORM), MIN is 1, MAX is 10


2. Example


'Back-End > Java_1' 카테고리의 다른 글

[Java] Thread pool  (0) 2016.10.10
[Java] Daemon Thread  (0) 2016.10.10
[Java] Naming Thread  (0) 2016.10.07
[Java] Joining a thread  (0) 2016.10.07
[Java] Call a run() directly instead start()  (0) 2016.10.07
블로그 이미지

리딩리드

,
donaricano-btn

Naming Thread

- The Thread class provides methods to change and get them name of a thread

- Each thread has a name

- we can change the name of the thread by using setName()


1. Syntax

- public String getName()

- public void setName(String name)


2. Example


'Back-End > Java_1' 카테고리의 다른 글

[Java] Daemon Thread  (0) 2016.10.10
[Java] Thread Priority  (0) 2016.10.07
[Java] Joining a thread  (0) 2016.10.07
[Java] Call a run() directly instead start()  (0) 2016.10.07
[Java] Sleeping a thread  (0) 2016.10.07
블로그 이미지

리딩리드

,
donaricano-btn

Joining a thread

- join() waits for a thread to die


1. Syntax

- public void join()throws InterruptedException

- public void join(long milliseconds)throws InterruptedException


2. Example



'Back-End > Java_1' 카테고리의 다른 글

[Java] Thread Priority  (0) 2016.10.07
[Java] Naming Thread  (0) 2016.10.07
[Java] Call a run() directly instead start()  (0) 2016.10.07
[Java] Sleeping a thread  (0) 2016.10.07
[Java] Thread Scheduler  (0) 2016.10.07
블로그 이미지

리딩리드

,