小编Cor*_*Lee的帖子

Java线程优先级无效

这是关于线程优先级的测试.代码来自Thinking in Java p.809

import java.util.concurrent.*;

public class SimplePriorities implements Runnable {
    private int countDown = 5;
    private volatile double d; // No optimization
    private int priority;

    public SimplePriorities(int priority) {
        this.priority = priority;
    }

    public String toString() {
        return Thread.currentThread() + ": " + countDown;
    }

    public void run() {
        Thread.currentThread().setPriority(priority);
        while (true) {
            // An expensive, interruptable operation:
            for (int i = 1; i < 10000000; i++) {
                d += (Math.PI + Math.E) / (double) i;
                if (i …
Run Code Online (Sandbox Code Playgroud)

java windows multithreading java-7

9
推荐指数
5
解决办法
1万
查看次数

标签 统计

java ×1

java-7 ×1

multithreading ×1

windows ×1