Refactoring Java Concurrent Programs Based on Synchronization Requirement Analysis

Binxian Tao, Ju Qian · 2014

Writing high quality concurrent programs is challenging. A concurrent program that is not well-written may suffer from coarse synchronization problems, e.g., overly-large critical sections, overly-coarse locks, and etc. These coarse synchronizations may introduce unnecessary lock contention and thereby affect the parallel execution of running threads. To optimize them, people suggest use refactorings, e.g., Split Lock refactoring and Split Critical Section refactoring, to gradually evolve the synchronization code for better parallelism. However, manually identifying the refactoring opportunities is difficult and by-hand code transformations are error-prone. To reduce the manual efforts, this paper proposes an automated refactoring approach for Java concurrent programs based on synchronization requirement analysis. It can automatically analyze the existing synchronization code to identify synchronization requirements. Bases on these requirements, we can find Split Lock, Split Critical Section, and Convert to Atomic refactoring opportunities and then make proper code transformation for each of them. Our experiment shows that the approach does find effective refactoring opportunities in real projects and can transform the refactorable code correctly. This indicates the approach could be helpful for concurrent program evolution.

Read the paper · More papers on PaperTik