<commit_before>package com.felix.crazyjava.item1604;

/**
 * Created with IntelliJ IDEA.
 * Description: 线程让步yield()方法
 * Author: Felix
 * Date: 2017/3/8
 * Time: 10:52
 */
public class YieldTest extends Thread {

    public YieldTest(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            System.out.println(getName() + " " + i);
            // 当i=20时，使用yield方法让当前线程让步
            if (i == 20) {
                Thread.yield();
            }
        }
    }

    public static void main(String[] args) {


        YieldTest yt1 = new YieldTest("高级");
        // 将yt1线程设置成最高优先级
        yt1.setPriority(Thread.MAX_PRIORITY);
        yt1.start();

        YieldTest yt2 = new YieldTest("低级");
        // 将yt2线程设置成最低优先级
        yt2.setPriority(Thread.MIN_PRIORITY);<commit_msg>线程控制小节代码<commit_after>package com.felix.crazyjava.item1604;

/**
 * Created with IntelliJ IDEA.
 * Description: 线程让步yield()方法
 * Author: Felix
 * Date: 2017/3/8
 * Time: 10:52
 */
public class YieldTest extends Thread {

    private YieldTest(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            System.out.println(getName() + " " + i);
            // 当i=20时，使用yield方法让当前线程让步
            if (i == 20) {
                Thread.yield();
            }
        }
    }

    public static void main(String[] args) {


        YieldTest yt1 = new YieldTest("高级");
        // 将yt1线程设置成最高优先级
        yt1.setPriority(Thread.MAX_PRIORITY);
        yt1.start();

        YieldTest yt2 = new YieldTest("低级");
        // 将yt2线程设置成最低优先级
        yt2.setPriority(Thread.MIN_PRIORITY);
{'fraction_non_alphanumeric': 0.12956419316843346, 'fraction_numerical': 0.03297997644287397, 'mean_word_length': 1.9242685025817556, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4936793', 'n_tokens_mistral': 682, 'n_tokens_neox': 654, 'n_words': 117}