Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ConcurentLinkedQueue<MyObject> queue;
- ResultSet rs = /* SELECT href from LINKS */;
- while(rs.hasNext()) {
- MyObject o = new MyObject(rs.next());
- queue.add(o);
- }
- /* create & start threads */
- for(int i = 0; i < 10; ++i) {
- MyThread t = new MyThread(queue);
- t.start();
- }
- /* inside MyThread */
- void threadMethod() {
- MyObject o = queue.poll();
- if(o != null) {
- /* process myobject */
- } else {
- System.out.println("no more items, thread shutting down.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement