Link to home
Start Free TrialLog in
Avatar of brianw13a
brianw13aFlag for United States of America

asked on

Communication between threads

Hello all,

I have just started a project that has me utilizing threads for the first time.  For the most part, everything seems to be working however I am at a crossroads and could use some advice.

I'll try to describe what is happening as best I can.  The app is a user interface that shows representation from hardware in the field (so far PLC values).  I order to obtain these values I must continously poll the devices as there are no message events.  The UI must always be accessible (no noticable delays) and has to 'read' and 'write' values out to the field devices.

So far I have a class that extends Thread and it seems to be working well.  I have started on the UI portion and it doesn't look like that will be a problem either.

I figure that the UI could dump requested device writes into a Hashtable and the device object could read the hashtable for requests before the next poll.

The problem that I have is in getting data changes from the device object to the UI.  I could really use a nudge in the right direction as I don't want to slow the polling down for UI updates.

Please only answer if you have threading experience and thank you in advance.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brianw13a

ASKER

CEHJ,

This looks like a winner however a lot of it is over my head.  Do you know of a link that explains how it all works?
Difficult to get a single link, but there's a similar question that's been asked recently - i'll try to find it ...
I think I've got it and will give it a try.  I did find another link that I found useful in addition to the one you have supplied.  Just in case someone else asks:

http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html

I'll let you know what happens and thanks
Sure
I've been reviewing the articles and the prvious discussion and I was wondering if we even need listeners.  It appears that the newly created thread is doing all the work without even utilizing the listener.  Am I correct or out to lunch?

Thanks
there are some examples of using the SwingWorker here:

http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html

Instead of listeners, you subclass it and overide the appropriate method(s) to hook in your app code.
>>It appears that the newly created thread is doing all the work without even utilizing the listener

Where do you mean exactly?
The previous experts post that you have refered to
Worked great!
8-)