42 lines
909 B
Java
42 lines
909 B
Java
|
|
/*
|
||
|
|
* ProcessManagerTestImplementation
|
||
|
|
*
|
||
|
|
* v1.0
|
||
|
|
*
|
||
|
|
* May 23, 2019
|
||
|
|
*/
|
||
|
|
|
||
|
|
|
||
|
|
package JobServ;
|
||
|
|
|
||
|
|
import java.util.concurrent.TimeoutException;
|
||
|
|
|
||
|
|
/*
|
||
|
|
* ProcessManagerTestImplementation
|
||
|
|
* inherits ProcessManager and adds useful functions for testing
|
||
|
|
*/
|
||
|
|
class ProcessManagerTestImplementation extends ProcessManager {
|
||
|
|
|
||
|
|
public void longCallHoldsLock() {
|
||
|
|
try {
|
||
|
|
super.getLock();
|
||
|
|
System.err.println("[1] Long Call Has Lock");
|
||
|
|
|
||
|
|
// hold lock for 7 seconds, more than double normal timeout.
|
||
|
|
Thread.sleep(4000);
|
||
|
|
|
||
|
|
super.releaseLock();
|
||
|
|
|
||
|
|
} catch (TimeoutException e) {
|
||
|
|
System.err.println("[!!] Long Call wasnt able to grab lock!");
|
||
|
|
return;
|
||
|
|
|
||
|
|
} catch (InterruptedException e) {
|
||
|
|
super.releaseLock();
|
||
|
|
System.err.println("[3] Released lock: interrupted");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|