calcthread.java
来自「利用JAVA实现的利用进化算法对人口增长进行仿真的源码」· Java 代码 · 共 57 行
JAVA
57 行
/*
* CalcThread.java
*
* Created on 13 October 2006, 14:23
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package wpc.threads;
import javax.swing.JTextArea;
/**
*
* @author craig
*/
public class CalcThread extends Thread{
wpc.data.World world;
wpc.MainFrame mainFrame;
/** Creates a new instance of CalcThread */
public CalcThread(wpc.MainFrame mainFrame) {
this.mainFrame = mainFrame;
}
public void run() {
mainFrame.debugAdd("Thread Info: Calculation Thread Started\n");
while (!mainFrame.getCreated()){
try {
Thread.sleep(1000);
//System.out.println("Checking");
} catch (InterruptedException e){
// the VM doesn't want us to sleep anymore,
// so get back to work
}
}
while (mainFrame.getStarted()) {
if(mainFrame.getRunning()){
mainFrame.getWorld().calcYear();
mainFrame.setYearPlus();
mainFrame.updateSidebar();
mainFrame.updateGraphics();
}
try {
Thread.sleep(mainFrame.getDelay());
//System.out.println("Checking");
} catch (InterruptedException e){
// the VM doesn't want us to sleep anymore,
// so get back to work
}
}
mainFrame.resetCalc();
mainFrame.debugAdd("Thread Killed\n");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?