All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.antmedia.logger.LoggerEnvironment Maven / Gradle / Ivy

Go to download

Ant Media Server supports RTMP, RTSP, MP4, HLS, WebRTC, Adaptive Streaming, etc.

There is a newer version: 2.10.0
Show newest version
package io.antmedia.logger;

import java.util.concurrent.atomic.AtomicInteger;

public final class LoggerEnvironment {

    protected static final ThreadLocal LOGGER_THREAD = ThreadLocal.withInitial(AtomicInteger::new);

    private LoggerEnvironment() {
    }

    public static void startManagingThread() {
        try {
            if (isManagingThread()) {
                //do nothing
            }
        } finally {
            LOGGER_THREAD.get().incrementAndGet();
        }
    }

    public static void stopManagingThread() {
        try {
            if (!isManagingThread()) {
                startManagingThread();
            }
        } finally {
            if (LOGGER_THREAD.get().decrementAndGet() == 0) {
                LOGGER_THREAD.remove();
            }
        }
    }

    public static boolean isManagingThread() {
        return LOGGER_THREAD.get().get() > 0;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy