zoukankan      html  css  js  c++  java
  • j.u.c: Java并发包的5大块

    //TODO

    Executors:

    ExecutorService executor = Executors.newFixedThreadPool(10);
    ... newForkJoinPool()...

    executor.submit (Callable<T> | Runnable)


    1. 内置锁

    2. Reentrant-Lock

    3. Stamped-Lock

    4. ReadWrite-Lock

    Semaphore

    锁是排他的、被锁住的code block 一次只能由唯一的线程在运行。 而Semaphore则可以提供指定数量的 permits, 允许最多指定数量的线程同时访问。

    适用场景:

    /**
    * Whereas locks usually grant exclusive access to variables or resources,
    * a semaphore is capable of maintaining whole sets of permits.
    * This is useful in different scenarios where you have to limit the amount concurrent access
    * to certain parts of your application.
    */


    Atomic Variables
    很简单的样子

    Concurrent Collections (线程安全的容器)

  • 相关阅读:
    使用rem,动态设置root font size
    手机陀螺仪
    获取图片
    插件整理
    jquery图片懒加载
    关于underscore.js
    PCA
    Endnote9
    实验问题记录
    DN/TOA/SR
  • 原文地址:https://www.cnblogs.com/nanlan2017/p/10317609.html
Copyright © 2011-2022 走看看