lock individual processes, not the whole queue
This commit is contained in:
parent
4cb9d3a5e1
commit
213d48c087
3 changed files with 110 additions and 110 deletions
|
|
@ -17,25 +17,28 @@ import java.util.concurrent.TimeoutException;
|
|||
*/
|
||||
class ProcessManagerTestImplementation extends ProcessManager {
|
||||
|
||||
public void longCallHoldsLock() {
|
||||
public void longCallHoldsLock(int pid) {
|
||||
try {
|
||||
super.getLock();
|
||||
super.getLock(pid);
|
||||
System.err.println("[1] Long Call Has Lock");
|
||||
|
||||
// hold lock for 7 seconds, more than double normal timeout.
|
||||
Thread.sleep(4000);
|
||||
|
||||
super.releaseLock();
|
||||
super.releaseLock(pid);
|
||||
|
||||
} catch (TimeoutException e) {
|
||||
System.err.println("[!!] Long Call wasnt able to grab lock!");
|
||||
return;
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
super.releaseLock();
|
||||
super.releaseLock(pid); // this doesnt happen, dont cancel this task
|
||||
System.err.println("[3] Released lock: interrupted");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean reportLockState(int pid) {
|
||||
return super.lockMap.get(pid);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue