Hi Zhou
The packing of two jar files is definitely no problems. I did same as you did. Because sever.jar supposed to run in difference computer or node, you are not able to use class path to get you reference you wanted.
What I did was that client.jar includes also the some classes i needs in suncertify.sever package. Therefore i no need to use the classpath to refer to skb class or other class.
Hi Douglas Kent
I did not identify any connection because lock/unclock are the methods to ensure threads race safe. in order to do this, i just make the Data class only have one instance to all connections by declare static in server.
I could give you the whole set of examples how the method block the other connections below, which may inspire your some thought. Pls note that the example is not
thread safe and could not use as real one, it just demonstrate your concerns
inData class:
private static boolean[] lockList= new boolean[recordCount+1];
//above lockList array auto initialized all false;
private static int recordUser=0;
public void lock(int record)throws DatabaseException, InterruptedException{
if(record==0| | record>recourdCount) throw new DatabaseException();// change the IO exception to DatabaseException will make you code ease
//whole database lock, lockList[0] reserved as database lock
if(record==-1) {
while(lockList[0]) //first, set databas lock true as soon as possible
sleep(100);
lockList[0]=true;
while(recordUser!=0) //second, check if any user there
sleep(100);
}
// individual record lock
else {
while(lockList[record] | | lockList[0])
sleep(100);
recoerdUser++;
lockList[record]=true;
}
}
public void unlock(int record){
if(record==0 | | record>recourdCount) return;
if(record==-1)
lockList[0]=false;
else{
recordUser--;
lockList[record]=false;
}
}
In the server, the applying of lock/unlock methods in server side like this;
static Data dt;
......
public DataInfo getRecord( int record) throws DatabaseException, RemoteException{
DataInfo di;
boolean exceptionOccured=false;
try{
dt.lock(record);
di=dt.getRecord(record)
}catch(InterrruptException){
exceptionOccured=true;
}finally{ // very important
dt.unlock(record);
if(exceptionOccured)
throw new DatabaseException(); //all exceptions must be rethrow after unlock method called
}
return di;
}
Remmber this is a demo for how to apply block different connection, it should be no hints or tempting to use it. It need rework to make it thread safe, I did not directly use it in my code.
David
[This message has been edited by david long (edited April 19, 2001).]