基于同步机制解决Java多线程安全问题的应用  被引量:2

Java Multi-thread Safety Problems Application Analysis Based on Synchronized Mechanism

在线阅读下载全文

作  者:陈益[1] 王佩 CHEN Yi;WANG Pei(School of Science, Hubei University of Technology, Wuhan 430068,China)

机构地区:[1]湖北工业大学理学院,湖北武汉430068

出  处:《软件导刊》2018年第12期165-168,172,共5页Software Guide

基  金:湖北省教育厅人文社科项目(17Q067);湖北工业大学校级教改项目(2015035)

摘  要:为了避免Java应用程序中多个线程共享同一个资源时产生访问冲突,确保线程安全,采用同步机制为每个线程合理地分配访问资源。编写一个模拟火车站售票过程的Java应用程序,由4个线程完成100张火车票的出售,调用sleep方法查看非同步环境下每个线程访问资源的状况。分析多线程采用同步机制和非同步机制的实验给系统带来的影响。实验证明,借助同步机制能合理地为每个线程提供没有任何冲突的资源访问,使Java多线程程序获得更好的健壮性。In order to avoid access conflicts when multiple threads in a Java application share the same resource and ensure thread safety,a synchronized mechanism is used to reasonably allocate access resources for each thread.We write a Java application that simulates the ticket sales process at the train station.The sale of100train tickets are completed by4threads,and the sleep method is called to check the status of each thread accessing resources in an asynchronous environment.The impacts of the experimental results of multi-threaded synchronization and non-synchronization mechanisms on the system are analyzed.Experiments show that the synchronization mechanism can reasonably provide each thread resource access without conflicts,which makes Java multi-threaded program execution more robust.

关 键 词:JAVA多线程 访问资源 线程安全 同步机制 健壮性 

分 类 号:TP319[自动化与计算机技术—计算机软件与理论]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象