##원문링크

프로세스와 쓰레드

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.

컴퓨터 시스템은 일반적으로 많은 활동적인 프로세스와 쓰레드를 가지고 있다. 싱글 코에서는 하나만 동작할 수 있으므로 한순간에는 한 스레드만 동작할 수 있다. (;;;;) 싱글코어는 타임슬라이싱이라고 불리는 OS 기능을 통해 프로세스와 스레드들간에 공유한다.(Processing time for ???)

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.

컴퓨터 시스템은 멀티 프로세서 또는 멀티 코어를 가지는건 점점 더 흔해지고 있다. 이건 시스템의 프로세스와 스레드의 병행 실행 능력을 훌륭하게 높여주였다. 하지만 병행성은 멀티프로세서 또는 멀티코어가 아니더라도 싱글코어 시스템에서도 가능하다.

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.

프로세스는 프로그램 또는 어플리케이션과 유의어로 종종 인지한다. 하지만 사용자가 단일 어플리케이션처럼 보이는것은 사실 협력적인 프로세스일수 있습니다. 프로스스간에 통신이 잘될려면, OS는 파이프, 소켓 같은 IPC(Inter Process Communication)을 지원한다. IPC는 단순히 동일 시스템내에서 프록세스간의 통신뿐만 아니라 다른 시스템의 프로세스들간에도 사용됩니다.(뭔가 어려움;;)

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.

거의 모든 자바 가상머신은 싱글 프로세스로 구현된다. 자바 어플리케이션은 ProcessBuilder 객체를 사용해서 추가 프로세스들을 만들수 있습니다. 멀티프로세스 어플리케이션은 이 수업의 범위를 넘기므로 없습니다.

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.

쓰레드

Threads

쓰레드는 때때로 가벼운 프로세스(lightwight processes)라고 불린다. 프로세스와 쓰레드는 실행환경을 제공하지만 새로운 프로세스를 생성하는 것보다 스레드를 생성하는게 자원 사용이 적다.

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.

쓰레드는 프로세스 안에 존재한다.(모든 프로세스는 최소한 하나의 스레드를 가진다.) 스레드는 프로세스의 메모리, 열린 파일등을 포함하여 자원을 공유한다. 이건 효과적이지만 잠재적으로 문제가 있습니다.(communication??)

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.

멀티쓰레드 동작은 자바 플랫폼의 필수적인 특징이다. 모든 어플리케이션은 최소한 하나의 (또는 여러개 )스레드를 가진다.메모리 관리와 시그널 핸들링과 같은 것과 같이 “시스템” 스레드를 셀 수 있습니다(???). 그러나 어플리케이션 프로그래머의 관점에서 보면 main 쓰레드라고 불리는 하나의 스레드로부터 시작합니다. 이 스레드는 추가 스레드를 생성하는 능력을 가졌다. 다음 섹션에서 설명하겠다.

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.