摘要
目前普遍采用急救包(Band-Aid)类库的方式解决Java线程模型存在的同步问题,但类库中的代码很难或无法实现优化。该文针对Java同步线程模型的缺陷,扩展synchronised关键字语法,使它支持多个参数和能接受一个超时说明;重新定义wait()使它返回一个boolean变量来解决超时检测问题;通过扩展语法方法解决了同步问题,以确保使用Java线程所开发的程序的稳定、可靠和可优化。
Java supports threading at language level.In order to synchronize,Java provides keyword "synchronized" and mechanisms like wait() for Object,however,the potential imperfectness of the mechanisms may trigger unpredictable results.Currently,"Band Aid" class library is often used to solve the synchronize problem of Java thread model,but it is hard to optimize the class library.The paper discusses drawbacks of Java threading mechanism,extends the grammar of synchronized keyword for accepting multiple parameters and a timeout callback;redefines wait() method for returning a boolean variable to solve the timeout detection issue.The synchronize issue is solved by using syntax extension methods to guarantee the stability,reliability and optimized attributes of the programs developed by Java threads.
出处
《电子科技大学学报》
EI
CAS
CSCD
北大核心
2010年第3期430-434,共5页
Journal of University of Electronic Science and Technology of China
基金
国家863计划(2007AA01Z131)
电子科技大学青年基金(L08010601JX0754)的资助