import threading


def run_thread(fun, *args, **kwargs):
    """
    Run function as background as thread
    
    :param fun: the function
    :param args: position args
    :param kwargs: key word args
        set_daemon_flg :[optional, default to false] if run thread in daemon mode
    :return: the thread instance
    """
    th = threading.Thread(target=fun, args=args, kwargs=kwargs)
    th.setDaemon(kwargs.get('set_daemon_flg', False))
    th.start()
    return th