Created
          August 22, 2013 10:35 
        
      - 
      
- 
        Save madsravn/6305691 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | if(con != null) { | |
| PreparedStatement findID = con.prepareStatement(query); | |
| findID.setInt(1, -1); | |
| ResultSet rs = findID.executeQuery(); | |
| //ResultSet rs = stmt.executeQuery(query); | |
| while(rs.next() && threads.size() < 5) { | |
| Thread t = new Thread(new MessageLoop(rs.getInt(1),con)); | |
| t.setDaemon(false); | |
| t.start(); | |
| threads.add(t); | |
| } | |
| } | |
| for(Thread thread : threads) { | |
| if(thread.isAlive()) { | |
| thread.join(1000); | |
| System.out.println("Waiting for "+ thread.getName()); | |
| } else { | |
| threads.remove(thread); | |
| System.out.println("Removing " + thread.getName()); | |
| System.out.println("Size = " + threads.size()); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment