收到## window
查看java进程 jps
杀进程 taskkill /f /pid
(1)再次提高性能。mater-work 模式,拆分任务 ,把一个任务继续拆分多个线程执行,并行执行,提高cpu执行效率 Fork-Join框架实现。
(2)空间换时间。持久化新进来,等于加大等待时间,通过对处理任务进行持久化到第三方组件上,例如消息队列,缓存。
package setMessage;
/**
* Created with IntelliJ IDEA.
* User: lixiao
* Created Date: 2021/1/20 23:21
*/
public class Main {
public static void main(String[] args) {
int result=0;
for (int k = 1; k <8 ; k++) {
int maxN= (int) Math.pow(2,k-1);
for (int n = 1; n < maxN+1; n++) {
result=mouth(k,n);
System.out.print(result);
}
System.out.println();
}
System.out.println( mouth(3,3));
}
public static int mouth(int k,int n){
int result=0;
boolean flag=true;
int moddle=0;
int n1=n;
for (int i = k; i > 2; i--) {
moddle = (int) Math.pow(2, i-2);
if(n1>moddle){
n1=n1-moddle;
flag=!flag;
}else if(n1==moddle){
result=i%2;
n1=0;
break;
}
}
if(n1==1){
result=0;
}if(n1==2){
result=1;
}if(n==0){
result=1;
}
if(!flag){
result=1-result;
}
return result;
}
}
package algorithm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @date 2021/1/22 14:44
*/
public class Mian {
public class Node {
public Node parent;
public Node l;
public Node r;
public Node(Node parent, Node l, Node r) {
this.parent = parent;
this.l = l;
this.r = r;
}
public Node getParent() {
return parent;
}
public Node getL() {
return l;
}
public Node getR() {
return r;
}
}
public Node Common(Node node1, Node node2) {
List<Node> nodeList1 = new ArrayList<>();
List<Node> nodeList2 = new ArrayList<>();
while (node1.parent != null) {
nodeList1.add(node1);
node1 = node1.parent;
}
while (node2.parent != null) {
nodeList2.add(node2);
node1 = node2.parent;
}
Collections.reverse(nodeList1);
Collections.reverse(nodeList2);
List<Node> nodeList3 = new ArrayList<>();
List<Node> nodeList4 = new ArrayList<>();
if (nodeList1.size() > nodeList2.size()) {
nodeList4 = nodeList3 = nodeList1;
} else {
nodeList4 = nodeList3 = nodeList2;
nodeList2 = nodeList1;
}
nodeList3.removeAll(nodeList2);
Node parentNex = nodeList3.get(0);
if (nodeList4.size() == 1) {
return nodeList4.get(0);
} else {
int nex = nodeList4.indexOf(parentNex);
return nodeList4.get(nex - 1);
}
}
}