• (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

     

     

  • 相关阅读:
    MySql 数据备份与还原
    PHP 连接数据库
    迭代法写线性回归
    ML numpy、pandas、matplotlib的使用
    005 动态加载实例
    爬虫实现案例
    004 使用scrapy框架爬虫
    003 爬虫持久化的三个不同数据库的python代码
    内置函数和匿名函数
    迭代器和生成器
  • 原文地址:https://www.cnblogs.com/ArrozZhu/p/8383317.html
Copyright © 2020-2023  润新知