zoukankan      html  css  js  c++  java
  • 【设计篇】线程与并发

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

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

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

      【调度的体现】

      多线程编程优化的时候,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();
  • 相关阅读:
    MySQL性能优化的最佳经验
    18个网站SEO建议
    sql之left join、right join、inner join的区别
    PHP与MYSQL事务处理
    Firefox上Web开发工具库一览
    SphinxSE的安装
    python XML
    python yaml
    C语言文本处理
    Linux strace命令
  • 原文地址:https://www.cnblogs.com/iCanhua/p/10080852.html
Copyright © 2011-2022 走看看