# Refactoring for Java-Structured Concurrency
## 7 Evaluation
### Research Questions
#### 7.3.1 Results of RQ1  
To answer RQ1, we counted the number of refactorable and non-refactorable code segments in each project, with the results summarized in Table 2. The second column shows the number of code snippets identified by the refactor probe. The third column shows the amount of refactorable code in each project. Columns 4 and 5 outline the specific reasons for the refactoring failures. Here, #NSF indicates that the _slutdownOnFailure_ strategy of the structured concurrency was not satisfied, and #CTP refers to the use of customized thread pools. The final column, \"Refactorable\", shows the proportion of the refactorable code in each project.  
Among these projects, a total of 99 unstructured concurrent code segments were detected, of which 82 were successfully refactored, resulting in an average refactorable rate of 82.82%. Among these projects, _SystemML_ contained the highest number of refactorable code segments, with a total of 48 unstructured concurrent code instances, of which 40 were successfully refactored, giving a refactorable rate of 83.33%. These code segments are primarily located in the _org.apache.sysml.runtime_ package in the module that handles large-scale machine-learning functionalities. Projects _Light-4j_, _TrackMate_, and _CodeJam_ achieved refactorable rates of 100%. The number of successful refactorings for _Light-4j_  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Project** & **Version** &
\begin{tabular}{c} **Non-Structured** \\ **Concurrency** \\ \end{tabular} & **LOC** \\ \hline SystemML & 3.2.0 & 48 & 412,560 \\ BigStitcher & 2.2.1 & 14 & 15,584 \\ Light-4j & 2.1.36 & 10 & 74,371 \\ MetaOmGraph & 1.8.1 & 10 & 80,177 \\ ModernJava & 1.0.0 & 7 & 23,045 \\ TrackMate & 7.10.0 & 5 & 58,873 \\ CodeJam & 1.0.0 & 5 & 11,106 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Information on these programs.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Project** & **Total** & **Refactored** & **NSF** & **CTP** &
\begin{tabular}{c} **Refactorable** \\ **(\%)** \\ \end{tabular} \\ \hline SystemML & 48 & 40 & 3 & 5 & 83.33 \\ BigStitcher & 14 & 10 & 0 & 4 & 71.43 \\ Light-4j & 10 & 10 & 0 & 0 & 100 \\ MetaOmGraph & 10 & 7 & 3 & 0 & 70 \\ ModernJava & 7 & 5 & 0 & 2 & 71.43 \\ TrackMate & 5 & 5 & 0 & 0 & 100 \\ CodeJam & 5 & 5 & 0 & 0 & 100 \\ \hline SUM/AVG & 99 & 82 & 6 & 11 & 82.82 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Refactoring results of ReStruct (1).  
is 10, _TrackMate_ is 5, and _CodeJam_ is 5. For TrackMate, it is mainly concentrated in the package _java.fiji.plugin.TrackMate.features_, which is responsible for calculating and tracking the relevant features of the objects, covering feature computation, storage management, and feature model construction. For the other projects, _BigStitcher_, _MetaOmGraph_, and _ModernJava_ had 10, 7, and 5 refactorable instances, with refactorable rates ranging from 70% to 71.43%.  
Upon examination of the statistical data, it was determined that refactoring was infeasible for 17 of the instances. The _SystemML_ project had a total of eight non-refactorable instances, five of which were because of the use of a customized thread pool, while the other three did not comply with the _shutdownOnFailure_ strategy. The projects _Light-4j_, _TrackMate_, and _CodeJam_ were able to complete all the refactorings. The project _MetaOmGraph_ had three instances that did not comply with the strategy _shutdownOnFailure_. In projects _BigStitcher_ and _ModernJava_, there were four instances in the first and two in the latter that could not be refactored because they used customized thread pools.