I want to loop over a huge array and do a complicated set of instructions that takes a long time. However, if more than 30 seconds have passed, I want it to give up.
You can use the fact that .allMatch() is a short-circuiting operator to terminate the stream:
final long start = System.currentTimeMillis();
myDataStructure.stream()
.allMatch(e ->
{
// your task here
return System.currentTimeMillis() <= start + 30000;
});