Test a thread in Java