JavaSE---Concurrency

2021-03-18 21:25

阅读:496

标签:空间   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


评论


亲,登录后才可以留言!