View difference between Paste ID: 4puxdTa4 and Dg9iqxCx
SHOW: | | - or go back to the newest paste.
1
ConcurentLinkedQueue<MyObject> queue;
2
3
ResultSet rs = /* SELECT href from LINKS */;
4
while(rs.hasNext()) {
5
  MyObject o = new MyObject(rs.next());
6
  queue.add(o);
7
}
8
9
/* create & start threads */
10
for(int i = 0; i < 10; ++i) {
11
  MyThread t = new MyThread(queue);
12
  t.start();
13
}
14
15
/* inside MyThread */
16
void threadMethod() {
17
  MyObject o = null;
18-
  while((o = queue.poll() != null) {
18+
  while((o = queue.poll()) != null) {
19
    /* process myobject */
20
  } 
21
  System.out.println("no more items, thread shutting down.");
22
}