Commit 72983cb7 by claincly Committed by Tofunmi Adigun-Hameed

Add utility to create ScheduledExecutorService

PiperOrigin-RevId: 538129792
(cherry picked from commit 13df52b97e64cf54071e130faa2c46001d6b7029)
parent 630abd83
......@@ -116,6 +116,7 @@ import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.DataFormatException;
......@@ -716,6 +717,16 @@ public final class Util {
}
/**
* Instantiates a new single threaded scheduled executor whose thread has the specified name.
*
* @param threadName The name of the thread.
* @return The executor.
*/
public static ScheduledExecutorService newSingleThreadScheduledExecutor(String threadName) {
return Executors.newSingleThreadScheduledExecutor(runnable -> new Thread(runnable, threadName));
}
/**
* Closes a {@link Closeable}, suppressing any {@link IOException} that may occur. Both {@link
* java.io.OutputStream} and {@link InputStream} are {@code Closeable}.
*
......
......@@ -34,7 +34,6 @@ import com.google.android.exoplayer2.util.Util;
import com.google.common.collect.ImmutableList;
import java.io.File;
import java.nio.ByteBuffer;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
......@@ -48,6 +47,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
*/
/* package */ final class MuxerWrapper {
private static final String TIMER_THREAD_NAME = "Muxer:Timer";
private static final String MUXER_TIMEOUT_ERROR_FORMAT_STRING =
"Abort: no output sample written in the last %d milliseconds. DebugTrace: %s";
......@@ -93,7 +93,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
trackTypeToInfo = new SparseArray<>();
previousTrackType = C.TRACK_TYPE_NONE;
abortScheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
abortScheduledExecutorService = Util.newSingleThreadScheduledExecutor(TIMER_THREAD_NAME);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment