I am querying all my 10 tables to get the user id from them and loading all the user id\'s into HashSet so that I can have unique user id.
As of now it is sequential
You may be able to make it multithreaded but with the overhead of thread creation and multiple connections, you probably won't have significant benefit. Instead, use a UNION statement in mysql and get them all at once. Let the database engine figure out how to get them all efficiently:
String sql = "select user_id from testkeyspace.test_table_1 UNION select user_id from testkeyspace.test_table_2 UNION select user_id from testkeyspace.test_table_3 ...."
Of course, you'll have to programatically create the sql query string. Don't actually put "...." in your query.