[Working] Adapt to multi thread