I want the fastest way to search all Ip addresses of the PC's connected to Lan using JAVA and placed all it in JCOMBOBOX?
<p>I want the fastest way to find all the IP addresses of the PCs connected to the Lan </p>

<pre><code>for(i=0;i&lt;255;i++)
</code></pre>

<p>This kind of the code takes too much for searching and displaying . I want display ip addresses in the combobox. It takes 8 minutes to run and find ip addresses connected to the Lan.</p>

<p>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package backupdropbox;</p>

<p>import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;</p>

<p>/**
 *
 * @author Administrator
 */
public class Threading {</p>

<pre><code>static InetAddress address;
static InetAddress localhost;
static Runnable r2 = new Runnable() {

    public void run() {



        try {
            localhost = InetAddress.getLocalHost();
        } catch (UnknownHostException ex) {
            Logger.getLogger(Threading.class.getName()).log(Level.SEVERE, null, ex);
        }
        // this code assumes IPv4 is used
        byte[] ip = localhost.getAddress();
        for (int i = 1; i &lt;= 50; i++) {
            ip[3] = (byte) i;
            try {
                address = InetAddress.getByAddress(ip);
            } catch (UnknownHostException ex) {
                Logger.getLogger(Threading.class.getName()).log(Level.SEVERE, null, ex);
            }
            //   System.out.println("address"+address);
            String ip1 = address.getHostAddress();
            try {
                if (address.isReachable(2000)) {
                    try {
                        Socket ServerSok = new Socket(ip1, 3260);
                        System.out.println("Port in use: " + address);
                        ServerSok.close();
                    } catch (Exception e) {
                    }
                }
            } catch (IOException ex) {
                Logger.getLogger(Threading.class.getName()).log(Level.SEVERE, null, ex);
            }

        }




    }
};
static Runnable r1 = new Runnable() {

    public void run() {



        try {
            localhost = InetAddress.getLocalHost();
        } catch (UnknownHostException ex) {
            Logger.getLogger(Threading.class.getName()).log(Level.SEVERE, null, ex);
        }
        // this code assumes IPv4 is used
        byte[] ip = localhost.getAddress();
        for (int i = 51; i &lt;= 100; i++) {
            ip[3] = (byte) i;
            try {
                address = InetAddress.getByAddress(ip);
            } catch (UnknownHostException ex) {
                Logger.getLogger(Threading.class.getName()).log(Level.SEVERE, null, ex);
            }
            //   System.out.println("address"+address);
            String ip1 = address.getHostAddress();
            try {
                if (address.isReachable(2000)) {
                    try {
                        Socket ServerSok = new Socket(ip1, 3260);
                        System.out.println("Port in use: " + address);
                        ServerSok.close();
                    } catch (Exception e) {
                    }
                }
            } catch (IOException ex) {
                Logger.getLogger(Threading.class.getName()).log(Level.SEVERE, null, ex);
            }

        }




    }
};





public static void main(String args[]) {

    Thread thr1 = new Thread(r1);
    Thread thr2 = new Thread(r2);


    thr1.start();
    thr2.start();


}
</code></pre>

<p>}</p>

<p>here is my code after creating threads</p>
