How can I iterate an array of objects that will change a few time a time, but while ensuring all items are iterated?
<p>I have a Java-based <a href="http://bukkit.org/" rel="nofollow">Bukkit</a> plugin (fairly irrelevant to the issue at hand but noteworthy) that will, every 30 minutes, query a web API for updates to pass on to users. </p>

<p>Here is the existing method, which works fine to pass every user to the API:</p>

<pre><code>public ApiMessenger()
{        
    TASK_ID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin,new Runnable()
    {
        @Override
        public void run()
        {
            if(Bukkit.getOnlinePlayers().length &gt; 0)
            {
                ApiMessenger.fetchPlayerItems(Bukkit.getOnlinePlayers(),true);
            }
        }
    }, 20*60*30, 20*60*30);
}
</code></pre>

<p>However the API will accept, at most, 30 users at a time. </p>

<p>So any server using this plugin that has more than 30 users on at a time will not be able to submit all their users at once, because the rest will be ignored. </p>

<p>What I'm trying to figure out is what kind of setup would allow me to store all the users with some form of a timestamp so that the ApiMessenger method shown above can remember which users have been sent and attempt to send the ones who have been waiting the longest for an update first.</p>

<p>I can manage removing/adding users as they join/leave, but my main concern is first creating a sorted data structure that can be updated as the groups of 30 users are sent. </p>

<p>Unfortunately I don't know which data types in Java to use to create such a structure that can be iterated in an ascending fashion.</p>
