public void run() { System.out.println("ReminderServiceOld: Starting at " + new Date()); while (!l.isEmpty()) { Date d = new Date(); Item i = (Item) l.get(0); long interval = i.due.getTime() - d.getTime(); if (interval > 0) { System.out.println("Sleeping until " + i.due); try { Thread.sleep(interval); } catch (InterruptedException e) { System.exit(1); // unexpected intr } message(i.due + ": " + i.message); } else message("MISSED " + i.message + " at " + i.due); l.remove(0); } System.exit(0); }
/** * Add the given file name to the list of recent files in the given Properties object, trimming * the length of the list to 10. If the given name is already in the list, move it to the top. */ public static void addRecentFile(Properties preferences, String newName) { // - if newName isn't already in the list, we add it to the top of the list. // - if it's already in the list, we move it to the top. ArrayList<String> list = MiscUtilities.parseRecentFiles(preferences); if (list.contains(newName)) { // move it to the top : list.remove(newName); list.add(0, newName); } else { list.add(0, newName); } // store to preferences : for (int i = 0; i < MAX_RECENT_FILES && i < list.size(); i++) { String key = KEY_RECENT_FILE + "." + Integer.toString(i + 1); // starts from 1 String val = list.get(i); preferences.setProperty(key, val); } }
public void addPoint(long handId, PVector handPoint) { ArrayList curList = getPointList(handId); curList.add(0, handPoint); if (curList.size() > _maxPoints) curList.remove(curList.size() - 1); }