阻塞队列的性能对比

    xiaoxiao2024-05-23  107

    主要是比较offer跟poll两个方法的性能,开N个线程,每个线程往队列里写或者取500个整数。 线程数20501002005001000LinkedBlockingQueue      15,031,1532,1663,32203,47563,110ArrayBlockingQueue15,016,1531,1547,16125,47364,68PriorityBlockingQueue78,78172,188360,422813,9693094,26416547,5453 逗号前的数字是offer测试花费的时间,逗号后的数字是poll测试花费的时间,单位毫秒。 结论: 1、ArrayBlockingQueue性能优于LinkedBlockingQueue,但是LinkedBlockingQueue是无界的。 2、ArrayBlockingQueue和LinkedBlockingQueue的poll方法总是比offer方法快,并发越高,差距越大 3、ArrayBlockingQueue和LinkedBlockingQueue的性能远高于PriorityBlockingQueue,显然优先队列在比较优先级上的操作上耗费太多文章转自庄周梦蝶  ,原文发布时间2008-09-08 相关资源:敏捷开发V1.0.pptx
    最新回复(0)