idk%eng.sun.com 6e4a0fdecc *not part of the build*
fix for 80938
a = avm@sparc.spb.su
    ovk@sparc.spb.su
    sva@sparc.spb.su

Tests for blackConnect


git-svn-id: svn://10.0.0.236/trunk@95860 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-24 05:22:13 +00:00

51 lines
1.4 KiB
Java

/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
*/
/*
* ExecutionThread.java
*/
import org.mozilla.xpcom.*;
import java.util.Date;
public class ExecutionThread extends Thread {
public static int MAX_TIMEOUT = 20000;
int timeout = Integer.MAX_VALUE;
public static long ID = 0;
iMThreadComponent component;
public ExecutionThread(iMThreadComponent component){
this.ID = new Date().getTime();
this.setName(Long.toHexString(ID));
this.component = component;
}
public ExecutionThread(iMThreadComponent component, int timeout){
this.ID = new Date().getTime();
this.setName(Long.toHexString(ID));
this.component = component;
if(timeout < MAX_TIMEOUT) {
this.timeout = timeout;
}else {
this.timeout = MAX_TIMEOUT;
}
}
public int timeoutGen() {
return (int)Math.round(Math.random()*MAX_TIMEOUT);
}
public void run(){
try {
if(timeout == Integer.MAX_VALUE) {
timeout = timeoutGen();
}
System.out.println("ExecutionThread(" + getName() + ") sleep to " + timeout);
sleep(timeout);
component.execute(getName());
} catch (Exception e) {
System.out.println("Execution thread had been interrupted");
}
}
}