본문 바로가기

Development Note

Processes and Threads

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
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 has many active processes and threads. This is true even in systems that only have a single execution core, and thus only have one thread actually executing at any given moment. Processing time for a single core is shared among processes and threads through an OS feature called time slicing.

보통 컴퓨터 시스템은 작동중인 많은 프로세스와 스레드들을 가지고 있습니다. 단일 실행 코어를 가지고 있는 시스템이나, 어떤 주어진 순간에 실제로 한 개의 스레드가 수행중일지라도 마찬가지입니다. 단일 코어를 위한 수행 시간은 OS 종류들이 time slicing 이라고 부르는 것을 통해서 프로세스들과 스레드들 사이에 공유되어집니다.


   It's becoming more and more common for computer systems to have multiple processors or processors with multiple execution cores. This greatly enhances a system's capacity for concurrent execution of processes and threads — but concurrency is possible even on simple systems, without multiple processors or execution cores.

다중 프로세스를 가지거나 다중 수행 코어를 가진 프로세스가 컴퓨터 시스템에서 점점 일반화 되어가고 있습니다. 이런 것들은 프로세스와 스레드의 동시다발적인 수행을 위한 시스템의 수용능력을 강화시킵니다.




Processes
프로세스
  A process has a self-contained execution environment. A process generally has a complete, private set of basic run-time resources; in particular, each process has its own memory space.

프로세스는 스스로 수행하는 실행 환경을 가지고 있습니다. 프로세스는 보편적으로 기본적인 수행 리소스들을 완벽히 갖추고 있습니다. 특별히 프로세스마다 각각 메모리 공간을 가지고 있습니다.


   Processes are often seen as synonymous with programs or applications. However, what the user sees as a single application may in fact be a set of cooperating processes. To facilitate communication between processes, most operating systems support Inter Process Communication (IPC) resources, such as pipes and sockets. IPC is used not just for communication between processes on the same system, but processes on different systems.

프로세스는 프로그램이나 어플리케이션과 동의어처럼 보입니다. 하지만 사용자가 보고 있는 하나의 어플리케이션이라는 것은 사실은 프로세스들의 조합입니다. 프로세스 간에 의사소통을 손쉽게 하기 위해서 대부분의 OS들은 pipe 나 socket 과 같은 IPC(Inter Process Communication) 리소스를 제공합니다. IPC는 같은 시스템에서 단지 프로세스 간의 의사소통만을 위해서 사용되어지지는 않습니다. 하지만 다른 시스템에서는 그렇게 되어 집니다.


Most implementations of the Java virtual machine run as a single process. A Java application can create additional processes using a ProcessBuilder object. Multiprocess applications are beyond the scope of this lesson.

JVM을 구현한 대부분의 것들은 단일 프로세스로 실행이 됩니다. 자바 어플리케이션은 ProcessBuilder 객체를 사용하여 프로세스를 추가적으로 만들 수 있습니다. 멀티프로세스 어플리케이션은 레슨의 뒤쪽 범위에 있습니다.



Threads
스레드
  Threads are sometimes called lightweight processes. Both processes and threads provide an execution environment, but creating a new thread requires fewer resources than creating a new process.

스레드는 가끔 저용량의 프로세스라고 부릅니다. 프로세스와 스레드 둘 다 실행환경을 제공하지만 새로운 스레드를 생성하는 것은 새로운 프로세스를 생성하는 것 보다 적은 리소스가 필요 합니다.


   Threads exist within a process — every process has at least one. Threads share the process's resources, including memory and open files. This makes for efficient, but potentially problematic, communication.

스레드는 프로세스 안에 존재 합니다.(모든 프로세스는 적어도 한 개의 스레드를 가지고 있습니다.) 스레드들은 프로세스의 메모리와 실행 파일 같은 리소스를 공유합니다. 이런 특징은 굉장히 효과적이지만 의사소통에 잠재적인 문제가 될 수 있습니다.



   Multithreaded execution is an essential feature of the Java platform. Every application has at least one thread — or several, if you count "system" threads that do things like memory management and signal handling. But from the application programmer's point of view, you start with just one thread, called the main thread. This thread has the ability to create additional threads, as we'll demonstrate in the next section.

멀티스레드 실행은 Java 플랫폼의 필수적인 특징입니다. 모든 어플리케이션은 적어도 한 개의 스레드를 가지고 있습니다. 만약에 메모리 관리와 신호 제어 같은 것을 하는 “시스템”이라고 불리 우는 스레드라면 여러 개 일 수 있습니다. 하지만 어플리케이션 개발자의 관점에서는 메인 스레드라고 불리우는 단 한 개의 스레드로 시작합니다. 이 스레드는 추가적인 스레드를 만드는 능력을 가지고 있습니다. 다음 섹션에서 데모를 보여드리도록 하겠습니다.