<commit_before>declare const global: any
export const that = global

that.self = global

that.console = {
    log(message) {
        java.lang.System.out.println(message)
    },
    error(message) {
        java.lang.System.err.println(message)
    },
}

that.setTimeout = (runnable: Function, delay = 0) => {
    let thread = new java.lang.Thread(() => {
        java.lang.Thread.sleep(delay)
        runnable()
    })
    thread.start()
    return thread
}

that.clearTimeout = (thread: java.lang.Thread) => {
    try {
        if (thread.isAlive()) thread.stop()
    } catch (ignored) {
    }
    thread.join()
}<commit_msg>Implement setInterval, clearInterval<commit_after>declare const global: any
export const that = global

that.self = global

that.console = {
    log(message) {
        java.lang.System.out.println(message)
    },
    error(message) {
        java.lang.System.err.println(message)
    },
}

that.setTimeout = (runnable: Function, delay = 0) => {
    let thread = new java.lang.Thread(() => {
        java.lang.Thread.sleep(delay)
        runnable()
    })
    thread.start()
    return thread
}

that.clearTimeout = (thread: java.lang.Thread) => {
    try {
        if (thread.isAlive()) thread.stop()
    } catch (ignored) {
    }
    thread.join()
}

that.setInterval = (runnable: Function, period) => {
    let executor = new java.util.concurrent.ScheduledThreadPoolExecutor(1)
    executor.scheduleAtFixedRate(runnable as any, period, period, java.util.concurrent.TimeUnit.MILLISECONDS)
    return executor
}

that.clearInterval = (executor: java.util.concurrent.ScheduledThreadPoolExecutor) => {
    if (!executor.isShutdown()) executor.shutdown()
}
{'fraction_non_alphanumeric': 0.1392857142857143, 'fraction_numerical': 0.0017857142857142857, 'mean_word_length': 2.9552941176470586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4768220', 'n_tokens_mistral': 548, 'n_tokens_neox': 537, 'n_words': 102}