if (list == null) {
threadList.set(new ArrayList<WeakReference<BagEntry>>(16));
}
else {
for (int i = list.size() - 1; i >= 0; i--) {
final BagEntry bagEntry = list.remove(i).get();
if (bagEntry != null && bagEntry.state.compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) {
return (T) bagEntry;
}
}
}