A. Bode et al. (Eds.): Euro-Par 2000, LNCS 1900, pp. 1053-1060, 2000. Springer-Verlag Berlin Heidelberg 2000 A More Expressive Monitor for Concurrent Java Programming 1 Hsin-Ta Chiao, Chi-Houng Wu, and Shyan-Ming Yuan Department of Computer and Information Science National Chiao Tung University 1001 Ta Hsueh Rd., Hsinchu 300, Taiwan {gis84532, gis86501, smyuan}@cis.nctu.edu.tw Abstract. The thread synchronization mechanism employed by Java is derived from the Hoares monitor concept. In order to minimize its implementation complexity, the monitor provided by Java is quite primitive. This design decision prefers simple concurrent objects and single-thread programs. However, we think the Java monitor is over simplified for developing more elaborated concurrent objects. Besides, several features of the Java monitor will bring extra overhead when thread contention gets higher. Currently, we have identified five drawbacks of the Java monitor. In this paper, we will first analyze these drawbacks in depth, and then propose a new monitor-based synchronization mechanism called EMonior. It has better expressive power, and introduces fewer overheads than the Java monitor when contention occurs. EMonior uses a preprocessor to translate the Java programs containing EMonitor syntax to regular Java programs that invoke EMonitor class libraries. It is very suitable to replace the Java monitor with the EMonitor when developing elaborate concurrent objects or high-contention concurrent systems. 1 The Introduction to Java Monitor The thread synchronization mechanism offered by Java is a monitor [5], which is a simplification of the original Hoares monitor concept [8]. For implementing monitors, each Java object contains a monitor lock and a condition queue. The keyword synchronize can be inserted into a methods definition for specifying it as a synchronized method. In each Java object, there is always only one synchronized method can be running at any moment. In addition to synchronized methods, Java also offers synchronized blocks for reducing the size of critical sections. Besides, for condition synchronization, Java provides the following three methods in each object: wait( ), notify( ), and notifyAll( ). They can be invoked only inside a synchronized method or inside a synchronized block. The design philosophy of Java monitor is to keep it as simple as possible. Consequently, its simplicity also leads to efficient implementation. All concurrent objects that can be implemented by the Java monitor easily will benefit from this design principle. Besides the multi-thread, concurrent programs, this design principle 1 This work was supported both by the National Science Council grant NSC88-2213-E-009-087 and the industry reaearch program 89-EC-2-A-17-0285-006 of the ROC Economic Bureau.