@Override
	//assumes that there is nothing in the buffer from other stuff
	//make sure other methods accessing the streams
	//are also synchronized
	public void run() {
		

		PrintWriter out;
		InputStreamReader reader;
		
		while(true) {
			//wait until ONE client connects
			synchronized(monitor) {
				try {
//					System.out.println("why waste the chanc?");
					monitor.wait();
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			try {
				//out = new PrintWriter(socket.getOutputStream(), true);
				//reader = new InputStreamReader(socket.getInputStream());
				char[] temp = new char[1];
				while(true) {
			    //System.out.println("stop");
                //synchronized(connectedClients) {
					lock.lock();
//				     System.out.println("LOCKED");
//				     System.exit(0);
					Iterator<ClientInfo> i = connectedClients.iterator();
					ClientInfo clientInfo;
					while(i.hasNext()) {
						clientInfo = i.next();
//					    System.out.println("CLIENT NAME: " + clientInfo.getClientName());
						out = new PrintWriter(clientInfo.getMainSocket().getOutputStream(), true);
						reader = new InputStreamReader(clientInfo.getMainSocket().getInputStream());
						out.write('a');
						if(out.checkError()) {
							//error so means the client has disconnected
							//remove from the list of clients
							System.out.println("\n" + clientInfo.getClientName() + " has disconnected!");
							//CLOSE COMMAND SOCKET DON'T FORGET. EVEN IF IT ALREADY CLOSED YOU DON'T KNOW!
							//actually WHEN PROGRAM DIES. ALL THESE SOCKETS ARE ASSUMED TO BE CLOSED.
							//CUZ THEY ALL DEAD LOL.
							//ALL OTHER SOCKETS ARE DEALT WITH ! :o
							//STILL CLOSE COMMAND SOCKET JUST IN CASE!
							//YOU KNOW MAIN SOCKET ALREADY DEAD ROFL CUZ U CAN'T WRITE FOR SHIT!
							//MAIN IS BY DEFAULT ALREADY CLOSED. THAT IS NOW WE GOT HERE. LOL.
							//EVERYTHING BELOW IS CLOSED JUST IN CASE. JUST FOR SAFE KEEPINGS.
							clientInfo.closeCommandSocket();
							clientInfo.closeAllSubSockets();
							
							//FINALLY REMOVE FROM THE ARRAY BYE BYE!
							i.remove(); //remove from the array
							findAndDeleteRow(clientInfo);
						} else { //success so read back so not mess up stream!
//					    	out.flush();
//							out.flush();
							reader.read(temp);
						}
//						System.out.println("WELL GO HOME!");
//						System.exit(0);
					}
					lock.unlock();
					if(connectedClients.size() == 0) {  //if size is zero, break and go enter that monitor synchronized block to wait until get notified.
						break;
					}
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
//					out.close(); //resets
//					reader.close();
//				}
//				for(ClientInfo clientInfo : clients) {
//					out = new PrintWriter(clientInfo.getSocket().getOutputStream(), true);
//					reader = new InputStreamReader(clientInfo.getSocket().getInputStream());
//					out.write('a');
//					if(out.checkError()) {
//						//error so means the client has disconnected
//						//remove from the list of clients
//						clients.remove(clientInfo);
//					} else { //success so read back so not mess up stream!
//						reader.read(temp);
//					}
//					out.close(); //resets
//					reader.close();
//				}
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
		
//		} catch (ConcurrentModificationException e) {
//			//does nothing because there is no harm at all.
			} catch(NullPointerException e) {
				e.printStackTrace();
			}
		}
//		return null;
		// TODO Auto-generated method stub
//		return null;
	}