基于Java synchronized同步锁实现线程交互  被引量:3

Realization of Thread Interaction Based on Java Synchronized

在线阅读下载全文

作  者:崔政 段利国[1] CUI Zheng;DUAN Liguo(Taiyuan University of Technology,Taiyuan 030024,China;Pingshun County Power Supply Company,Shanxi Power Company,Changzhi 047400,China)

机构地区:[1]太原理工大学,山西太原030024 [2]山西省电力公司平顺县供电公司,山西长治047400

出  处:《软件工程》2018年第2期1-3,共3页Software Engineering

基  金:山西省重点资助教学改革项目(面向工程教育专业认证持续改进的课程设计实施方案研究;J2017017)

摘  要:Java多线程能够提高CPU利用效率,但也容易造成线程不安全、线程死锁等问题。本文详细介绍了Java线程各状态之间的关系及其切换,并用实例展示了使用同步锁synchronized保证同一时刻只有一个线程操作同一资源,使用wait()、notify()切换线程状态保证线程操作的前后顺序实现线程交互。理解Java线程各状态之间的关系及其切换,能帮助用户在使用Java多线程的场景有效避免多线程带来的不安全问题。Java multi-threading can improve CPU utilization,but it can also cause problems such as thread insecurity and thread deadlock.This paper introduces in detail the relationship between Java thread states and their transitions.Java synchronized ensures that only one thread operates the same resource at the same time,using wait()and notify()to switch the thread state to ensure that thread interactions are implemented in the context of thread operations.Understanding the relationship between the states of Java threads and their switching can help users avoid effectively the unsafe problems of multi-threading in Java multi-threaded scenarios.

关 键 词:多线程 synchronized 线程交互 

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

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

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