'Back-End'에 해당되는 글 135건

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
블로그 이미지

리딩리드

,
donaricano-btn

Call a run() directly instead start()

- Each thread starts in a separate call stack, like this

- Invoking the run() from main thread, the run() method goes onto the current call stack 

1. Problem

- There is no context-switching 

- t1 and t2 will be treated as normal object not thread object


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

[Java] Naming Thread  (0) 2016.10.07
[Java] Joining a thread  (0) 2016.10.07
[Java] Sleeping a thread  (0) 2016.10.07
[Java] Thread Scheduler  (0) 2016.10.07
[Java] Creating thread  (0) 2016.10.05
블로그 이미지

리딩리드

,
donaricano-btn

Sleeping a thread

- It is used to sleep a thread for the specified amount of time


1. Syntax

- public static void sleep(long miliseconds)throws InterruptedExceptioin

- public static void sleep(long miliseconds, int nanos)throws InterruptedException


2. Example


- At a time only one thread is executed

- If you sleep a thread for the specified time, the thread schedular pick up another thread

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

[Java] Joining a thread  (0) 2016.10.07
[Java] Call a run() directly instead start()  (0) 2016.10.07
[Java] Thread Scheduler  (0) 2016.10.07
[Java] Creating thread  (0) 2016.10.05
[Java] Life cycle of a thread  (0) 2016.10.05
블로그 이미지

리딩리드

,
donaricano-btn

Thread Scheduler


1. What is it?

- Thread scheduler is the part of the JVM that decides which thread should run

- Only one thread at a time can run in a single process

- The Thread scheduler mainly uses preemptive or time slicing scheduling to schedule the threads


2. Different between preemptive and time slicing

1) preemptive

- The highest priority task executes until it enters the waiting or dead states

- A higher priority task comes into existence

2) time slicing

- A task executes for a predefined slice of time and then reenters the pool of ready tasks

- The scheduler then determines which task should execute next, based on priority and other factors


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

[Java] Call a run() directly instead start()  (0) 2016.10.07
[Java] Sleeping a thread  (0) 2016.10.07
[Java] Creating thread  (0) 2016.10.05
[Java] Life cycle of a thread  (0) 2016.10.05
[Java] Multithreading in java  (0) 2016.10.05
블로그 이미지

리딩리드

,