I want to send different XML message strings based on the time. I have thought of implementing a data structure in JAVA and put all the XML messages in it with the time when they should be sent out. I want to use sorted data structure so that every time the message comes inside the data structure, it gets sorted and while sending out I can check their respective times and take the messages out. I want to know which data structure would be most efficient and how can I implement it. Also how can I put time in seconds with each XML string.
It is like:
Message 1, time to send T + 1 ---- put to the data structure
Message 2, time to send T + 4 ---- put to the data structure
Message 3, time to send T + 3 ---- put to the data structure....
There will be a separate thread that will check the messages in the data structure every second and remove all the messages which qualifies to come out.