Apologies for the ambiguous title - I couldn't think how to word this for a title.
Basically, I'm playing around with creating a simple server/client programs in Java. My server runs a thread to constantly check for new connections, then if a connection is found - it creates a thread and a connection object just for that connection.
Problem comes in at the thread that checks for new connections - it didn't work, until I started error checking and when I added in the line:
System.out.println("");
It suddenly started to work as it should. Removing this line causes no new threads to be added for connections. I assumed it was providing enough delay for the thread to run properly or something, so I put in a for loop for a while to see if that worked - but nothing else has worked apart from that one simple line.
Here's the code for creating new connection threads:
    class ThreadCreator implements Runnable {
    ThreadCreator() {
    }
    public void run() {
        while(true) {
            System.out.println("WHY DOES THIS WORK??");
            for(int i = 0; i < connections.size(); i++) {
                if(connections.get(i).thread == false) {
                    Runnable ReadRunnable = new Read(connections.get(i));
                    Thread ReadThread = new Thread(ReadRunnable, "MWHAHAH");
                    ReadThread.setPriority(Thread.MAX_PRIORITY);
                    ReadThread.start();
                    connections.get(i).thread = true;
                    System.out.println("THREAD CREATED");
                }
            }
        }
    }
}
I can't imagine what could be going wrong..?
 
     
    