public ArrayList<Integer> doScan() {

        cancelled = false;
        openPortsFound.clear();

        ExecutorService executor = Executors.newFixedThreadPool(noThreads);

        for (int portNo : ports) {
            Runnable worker = new PortScanRunnable(address, portNo, timeOutMillis, method);
            executor.execute(worker);
        }

        // This will make the executor accept no new threads
        // and finish all existing threads in the queue
        executor.shutdown();
        // Wait until all threads are finish
        try {
            executor.awaitTermination(1, TimeUnit.HOURS);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Collections.sort(openPortsFound);

        return openPortsFound;
    }
Perform a synchronous (blocking) port scan and return a list of open ports

@return - ping result
library/src/main/java/com/stealthcopter/networktools/PortScan.java