![JAR search and dependency download from the Maven repository](/logo.png)
org.jcodec.player.util.ThreadUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcodec Show documentation
Show all versions of jcodec Show documentation
Pure Java implementation of video/audio codecs and formats
package org.jcodec.player.util;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
/**
* This class is part of JCodec ( www.jcodec.org ) This software is distributed
* under FreeBSD License
*
* @author The JCodec project
*
*/
public class ThreadUtil {
public static void surePut(BlockingQueue q, E el) {
while (true) {
try {
q.put(el);
break;
} catch (InterruptedException e) {
}
}
}
public static T sureTake(BlockingQueue audio) {
while (true) {
try {
return audio.take();
} catch (InterruptedException e) {
}
}
}
public static void sleepNoShit(long nanos) {
if (nanos < 0)
return;
try {
Thread.sleep(nanos / 1000000, (int) (nanos % 1000000));
} catch (InterruptedException e) {
}
}
public static void waitNoShit(Object o, int timeout) {
try {
o.wait(timeout);
} catch (InterruptedException e) {
}
}
public static void joinForSure(Thread thread) {
while (true) {
try {
thread.join();
break;
} catch (InterruptedException e) {
}
}
}
public static void waitNoShit(Object o) {
try {
o.wait();
} catch (InterruptedException e) {
}
}
public static T take(BlockingQueue videoDrain, int ms) {
try {
return videoDrain.poll(ms, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy