본문 바로가기

Thread

(4)
Multi-Threading ③ Thread Objects 일단 멀티 스레드로 작업을 하기 위해서는 Runnable 이라는 인터페이스를 구현(implements)하거나 Thread 클래스를 상속(extends)받는 두가지의 방법이 있습니다. 다시 말하면, run() 이라는 메소드가 있어야 하기 때문인데, Thread 클래스는 Runnable을 구현하고 있기 때문에 결국은 Runnable 인터페이스를 구현하는 셈이 되는거죠. /* * Runnable 인터페이스를 구현하는 경우 */ public class HelloRunnable implements Runnable { public void run() { System.out.println("Hello from a thread!"); } public static void main(String args[]) { (new..
Multi-Threading ② Features of Threads 자바에서의 스레드는 아래와 같은 특징이 있습니다. Share the process's resources Potentially problematic, communication - Concurrecy Problem - Too many synchronized - Deadlock Multithreaded execution is an essential feature of the Java platform 프로세스의 자원을 공유하고, 의사소통에서의 잠재적인 문제야기의 가능성이 있으며, 자바의 중요한 특징 중에 하나라는 점입니다. 첫째로, 프로세스의 자원을 공유한다는 말은, 프로세스 내부에 존재하는 스레드가 실행환경을 위해 모든 것을 갖추고 있는 프로세스의 자원을 사용하여 실행이 된다는 뜻이라는 것을 알 수 있습니다...
Defining and Starting a Thread Defining and Starting a Thread An application that creates an instance of Thread must provide the code that will run in that thread. There are two ways to do this: * Provide a Runnable object. The Runnable interface defines a single method, run, meant to contain the code executed in the thread. The Runnable object is passed to the Thread constructor, as in the HelloRunnable example: 스레드 인스턴스를 만든..
Processes and Threads Processes and Threads 프로세스와 스레드 In concurrent programming, there are two basic units of execution: processes and threads. In the Java programming language, concurrent programming is mostly concerned with threads. However, processes are also important. 동시발생의 프로그래밍에서 프로세스와 스레드라는 두 가지의 기본적인 실행 단위가 있습니다. 자바 프로그래밍 언어에서는 동시 수행의 프로그래밍은 대부분 스레드와 관계가 있습니다. 하지만 프로세스도 또한 중요합니다. A computer system normally h..