==========================================================================
while (running.get())
{
try
{
pp.manageClientDispatch(null);
if (pp.requestResults.size() > 0)
{
TTrequest request = pp.requestResults.poll();
if (request != null)
{
request.getMC().finishProcess();
}
}
}
catch(Throwable e)
{
logFatalToFile("TTdispatcher::run Error results size [" +
pp.requestResults.size() + "] " + e.toString(), e);
e.printStackTrace();
}
}
==========================================================================
The linked list requestResults has elements and the program runs but
suddenly starts throwing the following error from the exception catch
==========================================================================
25 Oct 2005 01:56:21 PDT: FATAL - {Thread-0} {Thread-3}
TTdispatcher::run Error results size [10] java.util.NoSuchElementException
java.util.NoSuchElementException
at java.util.LinkedList.remove(Unknown Source)
at java.util.LinkedList.removeFirst(Unknown Source)
at java.util.LinkedList.poll(Unknown Source)
at uk.co.ticketweb.TTserver.TTdispatcher.run(TTdispatcher.java:63)
at java.lang.Thread.run(Unknown Source)
==========================================================================
line 63 is the linked list poll line of code
This happens at random times in the running of the program.
Help.
Cheers,
Pep.
You appear to accessing the list from multiple threads with no attempt
at thread-safety. Place synchronized blocks around operations on the
list that you want to be done together (including single method calls).
Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
>This happens at random times in the running of the program.
Only a very few of the Collections are thread safe. See
http://mindprod.com/jgloss/threadsafety.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
> On Tue, 25 Oct 2005 10:04:04 +0100, Pep <p...@nowhere.com> wrote,
> quoted or indirectly quoted someone who said :
>
>>This happens at random times in the running of the program.
>
> Only a very few of the Collections are thread safe. See
> http://mindprod.com/jgloss/threadsafety.html
Thanks for the link, I'll have a good read of that.
Foolishly I thought that the collections were thread safe :(
Cheers,
Pep.
Thanks, Roedy has pointed that out to me. I was blindly assuming that the