Hello Dave,
> But how would be interupt the running process? In other words, he says
that
> another thread could set the boolean value to keep running to be false.
> Since EJB forbids concurrent access to the bean, he can spawn all the
client
> threads he wants, but only one thread at a time can be running in the
> session bean. So its impossible to interrupt the process.
The point is that the ejb processing is not interrupted by another thread.
It's interrupting itself. The method executeRule() returns after let's say
10 cycles. Take a look at the (current%number != 0) in the while
statement:
<Bean code>
...
private int number = 0;
private int current = 1;
...
public void ejbCreate(int n) {
number = n;
current = 1;
}
public boolean executeRule(){
while (EOF && (current%number != 0)){
read current record from file
process it
write back it to file
current++;
}
if (EOF) return true else return false;
}
</Bean code>
A Client, e.g. java application, can now decide to reinvoke the method or to
wait. Here you can use threads to implement a stop mechanism:
<Client code NOT AN EJB>
WorkingBean bean = WorkingBeanHome.create(10);
boolean done = false;
// another thread could set it to true, e.g. behind a stop button in a swing
GUI
boolean suspended = false;
while (!done) {
(if !suspended) {
done = bean.executeRule();
} else {
this.wait();
}
}
bean.remove();
</Client code NOT AN EJB>
regards,
--
[EMAIL PROTECTED]
MATHEMA Software GmbH
N�gelsbachstra�e 25 b
91052 E r l a n g e n
D e u t s c h l a n d
Tel +49(0)9131/8903-0
Fax +49(0)9131/8903-55
http://www.mathema.de
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".