Java API to manage thread easily