Passing multiple parameters from the command line in Java
Extract out the common logic before the if. The following is more or less the same:

noOfThreads = Integer.parseInt(args[0]);
noOfTasks = Integer.parseInt(args[1]);
startRange = Integer.parseInt(args[2]);
tableName1 = args[3];
databaseNames.add(tableName1);
if (args.length &gt;= 5) {
    tableName2 = args[4];
    databaseNames.add(tableName2);
}
if (args.length &gt;= 6) {
    tableName3 = args[5];
    databaseNames.add(tableName3);
}

Note that running the program with less than five parameters only prints an exception:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at ...Main.main(Main.java:16)


You should handle this and print a user friendly error message or usage help.