码迷,mamicode.com
首页 > 编程语言 > 详细

JavaSE---Concurrency

时间:2020-11-12 13:23:54      阅读:6      评论:0      收藏:0      [点我收藏+]

标签:空间   execution   code   proc   res   can   The   uil   set   

1、Processes and Threads

    In concurrent programming, there are two basic units of execution: processes and threads.(并发程序中,有2个基本的执行单位:进程、线程)

    1.1、Processes

        A process has a self-contained execution environment: complete, private set of basic run-time resources;each process has its own memory space.(一个进程有自己独立的运行环境:完整、私有的运行资源;  每个进程有自己的内存空间)

        Most implementations of the Java virtual machine run as a single process. A Java application can create additional processes using a ProcessBuilder object.(大多数JVM 运行在一个单独的进程中,一个Java应用也可以创建附加的进程)

    1.2、Threads

        Threads share the process‘s resources, including memory and open files.(多个线程共享同一个进程的资源:内存空间、打开的文件...)

2、Thread Objects

    Each thread is associated with an instance of the class Thread.(每个线程都是Thread的实例)

    There are two basic strategies for using Thread objects to create a concurrent application:(有2种使用线程对象的方式)

      a,To directly control thread creation and management, simply instantiate Thread each time the application needs to initiate an asynchronous task.(在应用每次需要异步任务时,创建线程)

      b,To abstract thread management from the rest of your application, pass the application‘s tasks to an executor.(将任务交给executor执行)

    

        

JavaSE---Concurrency

标签:空间   execution   code   proc   res   can   The   uil   set   

原文地址:https://www.cnblogs.com/anpeiyong/p/13793361.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!