static <A> A first_sync(L<A> list) {
  synchronized(list) {
    ret empty(list) ? null : list.get(0);
  }
}

static <A> A first_sync(Iterable<A> i) {
  if (i == null) null;
  synchronized(i) {
    Iterator<A> it = i.iterator();
    ret it.hasNext() ? it.next() : null;
  }
}