code: public synchronized void run(){	
  		while (true){
  			try {
  				if (incoming == null) {
  		            wait();	            
  		        }
  				
  				System.out.println("Socket opening ...");
  				BufferedReader in = new BufferedReader(new InputStreamReader(
  						incoming.getInputStream(), "UTF-8"));				
  				//PrintStream out = (PrintStream) incoming.getOutputStream();
  				BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
  						incoming.getOutputStream(), "UTF-8"));
  				
  				String content = "";
  				
  				while (true){				
  					int ch = in.read();
  					if (ch == 0) //end of string
  						break;
  					
  					content += (char) ch;
  				}
  				
  				//System.out.println(content);
  				String tagged = textpro.process(content);
  				//Thread.sleep(4000);
  				
  				out.write(tagged.trim());
  				out.write((char)0);
  				out.flush();
  			}
  			catch (InterruptedIOException e){
  				System.out.println("The conection is interrupted");	
  			}
  			catch (Exception e){
  				System.out.println(e);
  				e.printStackTrace();
  			}
  			
  			//update pool
  			//go back in wait queue if there is fewer than max
  			this.setSocket(null);
  			Vector<Session> pool = TaggingService.pool;
  			synchronized (pool) {
  				if (pool.size() >= TaggingService.maxNSession){
  					/* too many threads, exit this one*/
  					return;
  				}
  				else {				
  					pool.addElement(this);
  				}
  			}
  		}
  	}
docs: /* (non-Javadoc)
  @see java.lang.Thread#run()