1 19 20 package org.netbeans.modules.versioning.system.cvss; 21 22 import java.util.Collection ; 23 import java.util.List ; 24 import java.util.ArrayList ; 25 import java.util.Iterator ; 26 27 51 final class ExecutorGroupBar implements ExecutorGroup.Groupable { 52 53 private final Runnable action; 54 private final ExecutorSupport[] bar; 55 private ExecutorGroup group; 56 57 62 public ExecutorGroupBar(Collection executorsBar, Runnable action) { 63 this.action = action; 64 65 List filtered = new ArrayList (executorsBar.size()); 67 Iterator it = executorsBar.iterator(); 68 while (it.hasNext()) { 69 ExecutorGroup.Groupable groupable = (ExecutorGroup.Groupable) it.next(); 70 if (groupable instanceof ExecutorSupport) { 71 filtered.add(groupable); 72 } 73 } 74 75 bar = (ExecutorSupport[]) filtered.toArray(new ExecutorSupport[filtered.size()]); 76 } 77 78 public void joinGroup(ExecutorGroup group) { 79 this.group = group; 80 } 81 82 86 public void execute() { 87 group.enqueued(null, this); 88 ExecutorSupport.wait(bar); 89 if (action != null) { 90 action.run(); 91 } 92 group.finished(null, this); 93 } 94 } 95 | Popular Tags |