Untitled
unknown
plain_text
5 months ago
701 B
3
Indexable
/** * Fetch a non-empty list within a specified time limit. * * @param timeLimitMillis The maximum time to fetch in milliseconds. * @return A non-empty list or an empty list if the time limit is hit. */ public static List<String> getNonEmptyListWithTimeout(long timeLimitMillis) { List<String> resultList = new ArrayList<>(); long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < timeLimitMillis) { resultList = fetchList(); if (!resultList.isEmpty()) { break; // Stop fetching if a non-empty list is found } } return resultList; }
Editor is loading...
Leave a Comment