Instead of creating new threads to create a local lock, use Java local variables. Less respect for the assignment but much cleaner code.