首页> 中文期刊> 《河北工业科技》 >并行环境下Java哈希机制的对比及重构

并行环境下Java哈希机制的对比及重构

         

摘要

针对并行环境下出现的非线程安全问题,以哈希机制的Hashtable和ConcurrentHashMap的线程安全问题为切入点,设计了可改变线程总数和读写线程数的测试程序,分析了线程安全的ConcurrentHashMap和Hashtable的性能差异.根据性能差异,设计了从Hashtable到Concur-rentHashMap的程序自动重构插件,进而在Hashtable封装数据的情况下,通过对比传统多线程处理方式和Java8中的并行流处理方式的性能差异,分析了流处理方式相对普通多线程处理方式的高效性.对比结果显示,ConcurrentHashMap在并行程序中的性能要优于Hashtable.研究结果为多线程程序开发提出了解决非线程安全提供了较为可行的新思路,对于并行编程具有借鉴意义.%Aiming at the non-thread-safe under parallel environment,taking Hashtable and ConcurrentHashMap of Hash Mechanism as study obj ects,the test programs with variable numbers of threads and read-write threads are designed.The per-formance difference between ConcurrentHashMap and Hashtable is analyzed through the test program.According to the per-formance difference,the automatic refactoring of the program from Hashtable to ConcurrentHashMap is completed.Then in condition of the Hashtable encapsulation data, the performance difference between traditional multithreaded program processing and Java8 parallel stream handling approach is compared to analyze the effectiveness of parallel stream handling approach.The comparison result shows that the performance of ConcurrentHashMap in the parallel program is better than that of Hashtable.The research result provides new ways for solving non-thread-safe problems,which can be reference for parallel programming.

著录项

相似文献

  • 中文文献
  • 外文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号