Abstract:Compared with state diagram, activity diagram can be used to display the concurrent behavior of program in a more natural and intuitive way. Six primitives of initial, fork, join, flow final, activity final and activity were selected as the basis for graphical modeling and automatic code generation. A XML document format was defined to describe the activity diagram, then the XML document was parsed based on DOM, after that original activity diagram was split into separate activity sub-diagrams; and then each activity diagram was parsed into a number of processes and semaphores and codes. The methods and algorithms proposed were tested by designing and implementing a software system and good results were achieved, it showed that the methods and algorithms were right and effective.