Multithreaded String handling Java