Java同步线程模型分析与改进

Analysis and Improvement for Synchronous Thread Model Based on Java

  • 摘要: 目前普遍采用急救包(Band-Aid)类库的方式解决Java线程模型存在的同步问题,但类库中的代码很难或无法实 现优化。该文针对Java同步线程模型的缺陷,扩展synchronised关键字语法,使它支持多个参数和能接受一个超时说明;重新 定义wait()使它返回一个boolean变量来解决超时检测问题;通过扩展语法方法解决了同步问题,以确保使用Java线程所开发的 程序的稳定、可靠和可优化。

     

    Abstract: 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.

     

/

返回文章
返回