private void traverseStoreTasksToMemory() {
        instanceStore.getInstances(taskId).forEach((profileFromStore) -> {
            InstanceStateEnum storeState = profileFromStore.getState();
            Instance instance = instanceMap.get(profileFromStore.getInstanceId());
            switch (storeState) {
                case DEFAULT: {
                    if (instance == null) {
                        LOGGER.info("traverseStoreTasksToMemory add instance to mem taskId {} instanceId {}",
                                profileFromStore.getTaskId(), profileFromStore.getInstanceId());
                        addToMemory(profileFromStore);
                    }
                    break;
                }
                case FINISHED:
                    DELETE: {
                        if (instance != null) {
                            LOGGER.info("traverseStoreTasksToMemory delete instance from mem taskId {} instanceId {}",
                                    profileFromStore.getTaskId(), profileFromStore.getInstanceId());
                            deleteFromMemory(profileFromStore.getInstanceId());
                        }
                        break;
                    }
                default: {
                    LOGGER.error("instance invalid state {} taskId {} instanceId {}", storeState,
                            profileFromStore.getTaskId(),
                            profileFromStore.getInstanceId());
                }
            }
        });
    }
thread for core thread.

@return runnable profile.
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/instance/InstanceManager.java