Przeglądaj źródła

CPU任务

master
PoffyZhang 1 rok temu
rodzic
commit
c9460563e3
1 zmienionych plików z 12 dodań i 3 usunięć
  1. +12
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/CpuManage.java

+ 12
- 3
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/CpuManage.java Wyświetl plik

@@ -1,6 +1,5 @@
package com.ningdatech.pmapi.sys.manage;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@@ -11,11 +10,10 @@ import org.springframework.stereotype.Component;
* @Author PoffyZhang
*/
@Component
@AllArgsConstructor
@Slf4j
public class CpuManage {

private volatile Boolean isOpen = Boolean.FALSE;
private Boolean isOpen = Boolean.FALSE;

private int[][] matrix = new int[1][1];

@@ -23,6 +21,7 @@ public class CpuManage {
Double pow = Math.pow(10, i);
matrix = new int[pow.intValue()][pow.intValue()];
this.isOpen = Boolean.TRUE;
whileTrueTask();
}

public void close(){
@@ -36,8 +35,18 @@ public class CpuManage {
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
matrix[i][j] = i * j;
try{
Thread.sleep(10);
if(!isOpen){
break;
}
}catch (InterruptedException e){
log.error(e.getMessage());
}
}
}
}


}
}

Ładowanie…
Anuluj
Zapisz