WoTUG - The place for concurrent processes

CSP for Java: Multithreading for All

P. H. Welch
Computing Laboratory
University of Kent at Canterbury
CT2 7NF, England
+44 1227 823629
FAX: +44 1227 762811

G. H. Hilderink and A. P. Bakkers
Faculty of Electric Engineering
Control Laboratory
University of Twente
7500 AE Enschede
FAX: +31-53-4892223
G.H.Hilderink@el.utwente.nl, A.W.P.Bakkers@el.utwente.nl

G. S. Stiles
Department of Electrical and Computer Engineering
Utah State University
Logan UT 84322-4120
FAX: +1-435-797-3054

Proposal for a Technical (Educational) Session (120 minutes) at JavaOne 1999

October, 1998


Many internet, real-time and embedded applications are most naturally designed using concurrency. Unfortunately, the design of concurrent (multithreaded) programs has the reputation of being extremely difficult and dangerous, due to the possibility of deadlock, livelock, race hazards, or starvation - phenomena not encountered in single-threaded programs. Lea [1] emphasizes concern for the apparent difficulty: "Liveness considerations in concurrent software development introduce context dependencies that can make the construction of reusable components harder than in strictly sequential settings." Two approaches he suggests for design sound tedious and perhaps risky: "Top-down (safety first): Initially design methods and classes assuming full synchronization (when applicable), and then remove unnecessary synchronization as needed to obtain liveness and efficiency...Bottom up (liveness first): Initially design methods and classes without concern for synchronization policies, then add them via composites, subclassing, and related layering techniques..." Both suggest lengthy sessions of patching and testing until the application appears to work as desired.

Even those intimately connected with Java seem reluctant to employ more than a single thread. The Swing documentation states "If you can get away with it, avoid using threads. Threads can be difficult to use, and they make programs harder to debug. In general, they just aren't necessary for strictly GUI work, such as updating component properties" [2]. Oaks and Wong [3], also associated with Sun, are more positive, but note that "Deadlock between threads competing for the same set of locks is the hardest problem to solve in any threaded program. It's a hard enough problem, in fact, that we will not solve it or even attempt to solve it." Later they state "Nonetheless, a close examination of the source code is the only option presently available to determine if deadlock is a possibility..." and add that no tools exist for detecting deadlock in Java programs.

We feel, however, based on fifteen years of experience, that concurrent approaches are the best way to design most programs. Done properly (e.g., using CSP [4]) this results in better understanding of the problem and the solution, and leads to much cleaner implementations. A tremendous amount of work has been done on and with CSP in recent years, and the present state of the language and the tools offers the Java programmer excellent facilities for the design and analysis of multithreaded programs. Furthermore, Java designs based on CSP class libraries can now be verified against formal specifications and checked for deadlock and livelock with CASE tools - prior to implementation.

We present the CSP model (processes, channels, events, networks) and its binding into (100% Pure) Java through the CSP class libraries developed at Kent [5] and Twente [6]. We describe some of the tools associated with CSP (e.g., FDR [7]) and demonstrate, in several practical applications, their use for checking specifications and proving the absence of deadlock. We emphasize that CSP concepts are easy to understand and apply and that the engineering benefits they confer on system design and implementation are significant for both real-time and non-real-time multithreaded systems.


[1]Lea, Doug, Concurrent Programming in Java: Design Principles and Patterns, Addison-Wesley, Reading, MA, 1997.

[2]Muller, Hans, and Kathy Walrath, Threads and Swing, http://java.sun.com:80/products/jfc/swingdoc-archive/threads.html, April 3, 1998.

[3]Oaks, Scott, and Henry Wong, Java Threads, O'Reilly, Sebastopol, CA, 1997.

[4]The CSP Archive: http://www.comlab.ox.ac.uk/archive/csp/

[5]Java Communicating Sequential Processes (JCSP), http://www.hensa.ac.uk/parallel/languages/java/jcsp/, October, 1998.

[6]JavaPP, http://www.rt.el.utwente.nl/javapp/, October, 1998.

[7]Formal Systems (Europe) Ltd.: http://www.formal.demon.co.uk/, October, 1998.

Additional references on CSP, Java/CSP, and related topics may be found at



Peter Welch graduated in Mathematics from Warwick University in 1969, taking his Ph.D in Computer Science from the same institution in 1974. His doctoral research was on semantic models for the lambda-calculus, one of the key mathematical theories supporting functional programming. For the past 15 years, his main area of research and teaching has been in the field of parallel computing. He has made contributions to theoretical developments (e.g. CSP-based design rules for process network hierarchies with proven safety properties such as the absence of deadlock, livelock and starvation), tools supporting those rules, compilers for parallel languages, very lightweight CSP kernels (with sub-microsecond process management) and, recently, the CSP class libraries for Java. He has also worked on applications in the areas of real-time control, vision processing, networking and biological/physical system modelling. He is currently working on design rules for eliminating race-hazards from shared-memory multi-processing in the presence of dynamic memory allocation, higher level synchronisation primitives, SMP multi-threading kernels and the exploitation of these ideas in the Java world.

He was appointed Professor of Parallel Computing at the University of Kent at Canterbury (England) in 1989 and is the current Chairman of the World occam and/or Transputer User Group (WoTUG). He led the UK-funded "occam-for-all" project (1995-97) which has ported the CSP-derived occam multiprocessing language to a variety of modern parallel architectures. occam, because of its simplicity, security, lightness and formal semantics, remains a key research tool with relevance to the Java community as it struggles to come to terms with the problems and opportunities of multithreading. Professor Welch is one of the leading advocates for the transfer of technical knowledge from the now mature CSP community into the wider world of parallel computing, where the lack of basic theory and tools is an admitted problem and a serious obstacle to practice.

Professor Welch has over 50 refereed technical publications in academic journals and conferences. He has been an Invited Speaker at numerous international conferences (most recently VECPAR'98 in Portugal) and has been a regular presenter of workshops and tutorials on Java, CSP and parallel processing.


Home page:


The JCSP class libraries:


WoTUG-21 press release (re. Java/Sun's-thread-warnings/CSP):


Java Threads Workshop (1996):


The Internet Parallel Computing Archive:



André Bakkers has been appointed professor at the Dutch open university in the field of information technology with a special assignment in the area of real time and parallel systems. He is also working at the Control Laboratory of the University of Twente. In September 1977 he joined Twente University as a Senior Lecturer with the control systems and computer engineering group of the electrical engineering faculty. Together with the University of Kent he acquired two COMETT projects i.e. 'Occam and Transputer Engineering I and II'. The results of these projects have set an international standard on the education and training in the area of parallel systems. The results of these projects have been propagated at other universities in Europe, America, South Africa, Australia and Japan and have recently been incorporated into Java channel class libraries.

His present research covers the realization of real-time control systems using heterogeneous parallel processing. He has guided three Ph.D. students in this area. In 1998 he co-edited the WoTUG-21 conference, in 1997 he hosted the WoTUG-20 conference in Twente. In April 1991 he was co-editor of the TRANSPUTING'91 conference in Sunnyvale California. In April 1989 he organized the WoTUG-10 conference in Enschede.

He has successfully acquired from the Dutch National Science Foundation (STW) the project 'Implementation of real-time control algorithms using transputers' and the ESPRIT-project 'Parallel Computing Action' in addition to the above mentioned COMETT projects. He was a referee for the EU with the ESPRIT StatLog project. He is a consultant to several companies. He is also the Student Counselor for the IEEE at the University of Twente.

Gerald Hilderink is currently a Ph.D. student in computer engineering at the Control Laboratory of the University of Twente, The Netherlands. His main research interest is the development of a reliable foundation using formal methods for real-time and embedded system design. He is interested in proposing a new parallel model for real-time and embedded systems programming in Java. He has developed the CSP channel class concept for Java and has implemented the CTJ channel class library.

G. S. Stiles was graduated in Philosophy from the University of Washington in 1966 and received the MS and PhD degrees in Electrical Engineering from Stanford University in 1972 and 1975. His doctoral and post-doctoral work (at Los Alamos) was in computational aspects of space physics and engineering. Since moving to Utah State University, where he is currently a professor of Electrical and Computer Engineering, he has concentrated on applications and implementations of parallel computing, particularly in the areas of real-time and near real-time high-performance data acquisition and analysis and stochastic optimization algorithms. His present teaching and research interests are in concurrent systems engineering.

Professor Stiles was the founding Chair of the North American Transputer Users Group, was an associate editor of Transputer Communications, and is presently an editor of the Concurrent Systems Engineering Series of IOS Press. He has thirty refereed journal and conference proceedings, and has presented four workshops and tutorials at international conferences.

Home page:


Research projects:


Page last modified on 17th October 2001
Pages © WoTUG, or the indicated author. All Rights Reserved.
Comments on these web pages should be addressed to: www at wotug.org