Browse Source

CPU任务

tags/24080901
PoffyZhang 1 year ago
parent
commit
c9460563e3
1 changed files with 12 additions and 3 deletions
  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 View File

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


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


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


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


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


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


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


} }
} }

Loading…
Cancel
Save