Read up about "state machine". It is a rather fancy name for a very simple concept. Use a variable to keep track of where you are in the process.
Suppose task J is running. When it is finished it sets the value of the variable to 'K' and then the code for task K would be something like this pseudo code (only a little oversimplified)
if (taskDue == 'K') {
// do my stuff
if (i am finished) {
taskDue = 'L';
}
}
By choosing the appropriate ID for the next task things can be done in any order