double x = 9.29;
double y = 8.69;
double diff = floor((x - y)*100+0.5)/100.0;
Run Code Online (Sandbox Code Playgroud)
这给了我差异为0.6但我需要它为0.60(两个小数点)有人可以帮我这个吗?
我是Java新手.下面是代码作为线程和同步的示例.
public class A implements Runnable{
public synchronized void run(){
/*
some code here
*/
}
}
public class B {
public static void main(String[] args){
A obj1 = new A();
Thread t = new Thread(obj1);
A obj2 = obj1;
Thread t1 = new Thread(obj2);
t.start();
t1.start();
}
}
Run Code Online (Sandbox Code Playgroud)
现在这两个线程会相互阻塞同一个锁,还是会得到两个不同的锁?
谢谢!!