I'm working on a program right now that is a UDP server tied to a GUI administration interface. The UDP server runs as its own class and implements the Runnable
interface.
I decided that the best way to design the program would be to have the UDP server run as a thread in the background, and just update the GUI when an event happens (e.g. a user successfully authenticates to the service).
I'm not quite sure what data structure to use to pass information between the threads when the GUI thread is not waiting (per se) on this information in that it is performing other tasks as well. I've seen some classes like Futures
, but these only tell you when the task is done (not really a priority here) and the BlockingQueue
interface, but using a Queue
solution seems like I'd have to repeatedly poll the Queue until information was pushed onto it, and then react based upon what information was pushed onto the Queue.
Is there a data structure that I can use to "send" data from the server up to the GUI so it can update accordingly?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…