W
Wes Harrison
I am working on my first multithreaded application and have struck a serious
problem. In the main thread I start 2 new threads, one that creates a large
List (synchronised ArrayList actually) and the other that continually loops
through it printing out any new entries.
The problem is that sometimes (and only sometimes) the thread that prints
out the list entries appears to stall. I have placed print statements
throughout the thread's code and it just seems to stop right between two
print statements. There's nothing else between those two print statements.
So I figure the symptoms must be related to a multithreading issue but I
don't understand the subject well enough to debug it properly. I expect
that I have to synchronize some method or code block but I have no idea
where to start looking.
Do you think this is a thread-related issue? What should I be synchronizing
and where?
Any help greatly appreciated. I can't post the code as my employer won't
allow it.
Wes
problem. In the main thread I start 2 new threads, one that creates a large
List (synchronised ArrayList actually) and the other that continually loops
through it printing out any new entries.
The problem is that sometimes (and only sometimes) the thread that prints
out the list entries appears to stall. I have placed print statements
throughout the thread's code and it just seems to stop right between two
print statements. There's nothing else between those two print statements.
So I figure the symptoms must be related to a multithreading issue but I
don't understand the subject well enough to debug it properly. I expect
that I have to synchronize some method or code block but I have no idea
where to start looking.
Do you think this is a thread-related issue? What should I be synchronizing
and where?
Any help greatly appreciated. I can't post the code as my employer won't
allow it.
Wes