Skip to content

Instantly share code, notes, and snippets.

@madsravn
Created August 22, 2013 10:35
Show Gist options
  • Save madsravn/6305691 to your computer and use it in GitHub Desktop.
Save madsravn/6305691 to your computer and use it in GitHub Desktop.
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