【翻译二】java--并发之进程与线程
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.
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.
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
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--并发之进程与线程的更多相关文章
- Java中的进程和线程
Java中的进程与线程 一:进程与线程 概述:几乎任何的操作系统都支持运行多个任务,通常一个任务就是一个程序,而一个程序就是一个进程.当一个进程运行时,内部可能包括多个顺序执行流,每个顺序执行流就是 ...
- Java中的进程与线程(总结篇)
详细文档: Java中的进程与线程.rar 474KB 1/7/2017 6:21:15 PM 概述: 几乎任何的操作系统都支持运行多个任务,通常一个任务就是一个程序,而一个程序就是一个进程.当一个进 ...
- java 获取当前进程id 线程id
java 获取当前进程id 线程id RuntimeMXBean (Java Platform SE 8 ) https://docs.oracle.com/javase/8/docs/api/j ...
- Java 多线程详解(二)------如何创建进程和线程
Java 多线程详解(一)------概念的引入:http://www.cnblogs.com/ysocean/p/6882988.html 在上一篇博客中,我们已经介绍了并发和并行的区别,以及进程和 ...
- Java并发编程:进程和线程的由来(转)
Java多线程基础:进程和线程之由来 在前面,已经介绍了Java的基础知识,现在我们来讨论一点稍微难一点的问题:Java并发编程.当然,Java并发编程涉及到很多方面的内容,不是一朝一夕就能够融会贯通 ...
- JAVA基础知识|进程与线程
一.什么是进程?什么是线程? 操作系统可以同时支持多个程序的运行,而一个程序可以狭义的认为就是一个进程.在一个进程的内部,可能包含多个顺序执行流,而每个执行流就对应一个线程. 1.1.进程 进程:是计 ...
- (转)java中的进程与线程
(转自地址http://www.ibm.com/developerworks/cn/java/j-lo-processthread/) Java 进程的建立方法 在 JDK 中,与进程有直接关系的类为 ...
- Java多线程之进程和线程
在并发编程中有两个基本的概率就是进程和线程.在Java编程中并发编程更多的是关注线程.但是进程也是很重要的. 一个计算机一般会有很多活跃的进程和线程.有一点是没有疑问的在单核系统中,任何时候实际上都是 ...
- java中的进程与线程及java对象的内存结构【转】
原文地址:http://rainforc.iteye.com/blog/2039501 1.实现线程的三种方式: 使用内核线程实现 内核线程(Kernel Thread, KLT)就是 ...
随机推荐
- JS中try....catch
1.事情还有得挽回,换条路走try { 执行某个逻辑} catch (e) { 出问题,换个逻辑执行} 2.体面的退出try { 正常流程} catch (e) { 弹个框告诉用户不好意思出了点问题 ...
- Hashtable和HashMap的区别举例
我们先看2个类的定义 public class Hashtable extends Dictionary implements Map, Cloneable, java.io.Serializable ...
- dp重拾-完全背包--HDU 4508
减肥记 湫湫给了你每日食物清单,上面描述了当天她想吃的每种食物能带给她的幸福程度,以及会增加的卡路里量. Input 输入包含多组测试用例. 每组数据以一个整数n开始,表示每天的食物清单有n种食物. ...
- Java WebClient 总结
private WebClient getAWebClient() { WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24); ...
- django xadmin 插件(2) 列表视图新增一功能列
以默认的related_link为例(即最后一列). 源码:xadmin.plugins.relate.RelatedMenuPlugin class RelateMenuPlugin(BaseAdm ...
- nginx配置多域名映射方法(本地hosts)
本地测试网站的时候如果不想用localhost/xxxx的形式访问,可能就需要修改hosts文件来映射了,但是一个网站还好,假如有多个网站的话就不行了. 这时就需要配置多域名映射 比如hosts中配置 ...
- zaqar项目介绍
Zaqar is a multi-tenant cloud messaging and notification service for web and mobile developers. It c ...
- 【GoLang】golang HTTP GET/POST JSON的服务端、客户端示例,包含序列化、反序列化
服务端代码示例: package main import ( "encoding/json" "fmt" "io/ioutil" " ...
- 基于MATLAB的离散小波变换
申明,本文非笔者原创,原文转载自: 基于Matlab的离散小波变换 http://blog.sina.com.cn/s/blog_725866260100ryh3.html 简介 在 ...
- reportng的使用
1.首先安装testng 2.下载reportng jar包 http://pan.baidu.com/s/1i3KdlQH 3.添加到project build path 注意:需要同时引入goog ...