Have you considered using futures and executors for this instead of manually creating threads?