package com.tsi.app.common.xnet;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class NetWorkerThread extends Thread {

    private UncaughtExceptionHandler uncaughtExceptionalHandler = (t, e) -> handleException(t.getName(), e);

    public NetWorkerThread(String threadName) {
        super(threadName);
        setUncaughtExceptionHandler(uncaughtExceptionalHandler);
    }

    protected void handleException(String thName, Throwable e) {
        log.error("Exception occurred from thread {}, {}", thName, e);
    }
}
