- FileUtils.wirteStringToFile(…)是否支持多线程?
- class static variable initialization
there are 2 ways to init a class static variable: - Usage of HashMap, Hashtable, ConcurrentHashMap
单线程 情况下用HashMap;multithreads强调synchronization用Hashtable,因为Hashtable是对整个map锁定; multithreads强调效率,用ConcurrentHashMap,因为它仅对部分数据结构锁定; - Lambda expression
Lambda表达式也不是什么新东西,一句话概括就是实现只有1个abstract method的interface
- NaN of double
assuming d is a double, boolean expression d==Double.NaN always return false even if d==Double.NaN
Instead Double.isNaN(d) should be used - This is a vb tip to handle char “
Dim dq As String
dq = """123" ‘”” is used to parse “
Anad the result is to get a string “123 - Rmi
Surely there is an rmi thread pool to execute object methods. So for each call to obj.method(), should jvm fork a new thread to execute it? No, for each call of registry.lookup(url) in client’s thread A, a stub is returned. Subsequent calls to stub.method() in this client’s thread A will all be executed in same server thread.
比如多个线程写同一文件
这个link的答复似乎是不支持
However if you try e.g. to write to the same file from within multiple threads you may have some problems.
但在windows上测试的结果是没有问题的,似乎FileOuputStream的内部实现,自动同步了多个线程race condition
public static int mB=10; //way1
static {
mB=5; //way2
}
which one is done firstly? way1, so way2 will override way1.
import Java.util.*;
public class GFG {
public static void main(String[] args) throws Exception
{
List<String> arr1 = new ArrayList<String>();
int count = 0;
arr1.add("Geeks");
arr1.add("For");
arr1.add("Geeks");
arr1.stream().forEach(s -> {
// print all elements
System.out.print(s);
});
}
}
forEach中就是1个Lambda表达式,实现了Consumer接口中的accept(T) method,Consumer中唯一的abstract method