Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Xavier Casals

Greenhorn
+ Follow
since Aug 16, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Xavier Casals

Have you tried to use 'setSoTimeout'? It interrupts accept() when timeout expires. Then you can decide if you want to finish or not. Is like an active wait ... but I don't know if there is a better solution.
I have never programmed with sockets in Java, but I think it can work ...
I suppose that it happens because the two threads can access the variable 'i' at the same time. And the variable 'i' can be incremented twice before reading the line where you compare the value of 'i' with 10. You had to use a mechanism to prevent it (the line with i++ has to be executed like an atom with the comparison).
If there was only one thread, it has to work because there is only one access at the same time.
Try to use > instead of ==, and I am sure that it will exit from the loop!
I hope it helps you.
So, the ONLY way to exit a thread is exiting its run method?
What happens if it is not possible. For example, if we have a blocking call in the highest level (and the only exceptions that can be caught are the ones thrown by it).

Any suggestions?
I use the Jasper Package in order to execute Prolog processes from java. I can have a Prolog process in an infinite loop and I want to be able to kill this process!!
When I execute a Prolog process I send it to a thread (with which I can handle it better). The thread seems like:

How can I kill the thread or the Prolog process?
Otherwise, how can I exit the run() method?

[This message has been edited by Xavier Casals (edited August 16, 2001).]