@Override
	public void run()
	{
		try
		{
			int faills = 0;
			while(!closing)
			{
				//if there are task pending perform them.
				if(task != 0)
				{
					if(task == 1)
					{
						getNickFromClient();
						task = 0;
					}
				}
				
				//else just read normal input.
				String line;
				if((line = input.readLine()) != null)
				{
					faills = 0;
					useData(line);
				}
				else
					faills++;
				
				if(faills >= 10)
					closing = true;
			}
			
			log.log(Level.FINE,"Started Client connection kill " + threadId);
			
			input.close();
			output.close();
			
			socket.close();
			
			serverInstance.nullifyThread(threadId);
		
		}	
		catch (IOException | NullPointerException e)
		{
			//there will always be an null pointer exception on thread kill
			//and it will not cause any problems, because once the array reaches it's end
			//the null will be rewritten.
			
			if(e instanceof IOException)
			{	
				log.log(Level.SEVERE,"Error in client thread!");
				e.printStackTrace();
			}
		}
	}