• 【设计篇】线程与并发


        对象是过程的抽象,线程是调度的抽象;

        分离并发和业务代码:生产者-消费者、读者写者模型、宴席哲学家问题(筷子问题)

    • 互斥
    • 线程饥饿
    • 死锁
    • 活锁

      【调度的体现】

      多线程编程优化的时候,yield有小妙用,马上放弃自己!让出调度

     1  /**
     2      * A hint to the scheduler that the current thread is willing to yield
     3      * its current use of a processor. The scheduler is free to ignore this
     4      * hint.
     5      *
     6      * <p> Yield is a heuristic attempt to improve relative progression
     7      * between threads that would otherwise over-utilise a CPU. Its use
     8      * should be combined with detailed profiling and benchmarking to
     9      * ensure that it actually has the desired effect.
    10      *
    11      * <p> It is rarely appropriate to use this method. It may be useful
    12      * for debugging or testing purposes, where it may help to reproduce
    13      * bugs due to race conditions. It may also be useful when designing
    14      * concurrency control constructs such as the ones in the
    15      * {@link java.util.concurrent.locks} package.
    16      */
    17     public static native void yield();
  • 相关阅读:
    3、生成证书请求文件
    2、申请苹果App ID
    登录iOS Dev Center
    SQL Server 合并行
    asp 月末 月初
    linux
    ASP数组全集,多维数组和一维数组[转]
    oracle 秒
    oracle 存储过程 包 【转】
    linux
  • 原文地址:https://www.cnblogs.com/iCanhua/p/10080852.html
Copyright © 2020-2023  润新知