Something like:
long start_time = System.currentTimeMillis();
long wait_time = 10000;
long end_time = start_time + wait_time;
while (System.currentTimeMillis() < end_time) {
//..
}
Should do the trick. If you need other conditions as well then just add them to the while statement.