(Java学习笔记) Java Threading (Java线程)

Java Threading (Java线程)

● Process & Thread

Processes are the abstraction of running programs: A binary image, virtualized memory, various kernel resources, an associated security context, and so on.

Threads are the unit of execution in a process: A virtualized processor, a stack, and program state.

 

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.

 

● Processes

--Will by default not share memory

--Most file descriptors not shared

--Don't share filesystem context

--Don't share signal handling

 

● Threads

--Will by default share memory

--Will share file descriptors

--Will share filesystem context

--Will share signal handling

 

● Thread pool

Thread pool represents a group of worker threads that are waiting for the job and reuse many times,

 

● Thread life cycle & states

 

 

转载于:https://www.cnblogs.com/ArrozZhu/p/8383317.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值