Find last zero in infinite stream of 0's followed by 1's
You might have misunderstood the program requirements: an ArrayList is not an infinite Stream.



If you don't want a stream and do instead want to assume that multiple-threads are adding to it then you shouldn't use ArrayList because it's not thread-safe; apparently, a better alternative for that purpose would be Vector.