检索规则说明:AND代表“并且”;OR代表“或者”;NOT代表“不包含”;(注意必须大写,运算符两边需空一格)
检 索 范 例 :范例一: (K=图书馆学 OR K=情报学) AND A=范并思 范例二:J=计算机应用与软件 AND (U=C++ OR U=Basic) NOT M=Visual
作 者:陈益[1] 王佩 CHEN Yi;WANG Pei(School of Science, Hubei University of Technology, Wuhan 430068,China)
出 处:《软件导刊》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[自动化与计算机技术—计算机软件与理论]
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在链接到云南高校图书馆文献保障联盟下载...
云南高校图书馆联盟文献共享服务平台 版权所有©
您的IP:216.73.216.112