Threading testing using java