小编Pol*_*ris的帖子

PS1 env 无法在新 Mac Catalina 上解析

我的 PS1 变量无法正确解析,看起来像这样,

\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]mv .bashrc .bash_profile
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]source .bash_profile
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]ls
Applications    Desktop     Documents   Downloads   Google Drive    Library     Movies      Music       Pictures    Public
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]vim .bash_profile
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]source .bash_profile
\[\e[;31m\][\u@\h \W]$ \[\e[m\]
\[\e[;31m\][\u@\h \W]$ \[\e[m\]
\[\e[;31m\][\u@\h \W]$ \[\e[m\]
\[\e[;31m\][\u@\h \W]$ \[\e[m\]
Run Code Online (Sandbox Code Playgroud)

发生了什么?谢谢。

macos shell ps1

8
推荐指数
1
解决办法
3750
查看次数

Java Parallel Stream 与 ExecutorService 的性能

假设我们有一个列表并且想要选择满足某个属性的所有元素(比如一些函数 f)。有 3 种方法可以并行执行此过程。

一 :

listA.parallelStream.filter(element -> f(element)).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)

二:

listA.parallelStream.collect(Collectors.partitioningBy(element -> f(element))).get(true);
Run Code Online (Sandbox Code Playgroud)

三:

ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
//separate the listA into several batches
for each batch {
     Future<List<T>> result = executorService.submit(() -> {
          // test the elements in this batch and return the validate element list
     });
}
//merge the results from different threads.
Run Code Online (Sandbox Code Playgroud)

假设测试功能是 CPU 密集型任务。我想知道哪种方法更有效。非常感谢。

java parallel-processing java-stream java-threads

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