Consider the following scenario. Class A creates and starts a thread. This thread ( called LocalServer ), uses ServerSocket(0) to choose a port that is available, and listens for incoming connections on that port. The port on which the LocalServer is listening must be passed to A, so that A can connect to it. How can we ensure that the LocalServer is blocking on accept, and only then will A try connecting to it ? Consider the following piece of code : Class A { private int port; public A( ) { /* instantiate a LocalServer Object and start it */ localServer = new LocalServer(this); new Thread(localServer).start(); .. /* connect to LocalServer */ Socket s = new Socket(localhost, port); } void setPort(int p) { port = p; } } class LocalServer implements Runnable { private ServerSocket serverSock; LocalServer(A obj) { /* create a serverSocket and pass the port to A */ serverSock = new ServerSocket(0); obj.setPort(serverSock.getLocalPort()); } run( ) { Socket s = serverSock.accept(); ... ... } } In this above scenario, it is possible that the new thread that is started does not enters its run() method, but the Linux javavm gives less priority to it, so the thread does not reach the accept( ) immediately. If by this time, A tries to open a socket connection to the Local Server, it will fail ! Is there a way to ensure that the server is blocking on accept and only then A tries to connect ? Thanks in advance, Nandakumar. ---------------------------------------------------------------------- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]