synchronizing threads - How to speed up applications using threads in java