📄 docallstuff.java
字号:
/*
* DoCallStaff.java
*
* Created on 2007年9月14日, 上午12:21
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package newThread;
import java.util.concurrent.Callable;
/**
*
* @author Administrator
*/
public class DoCallStuff implements Callable<String>{ // *1
private int aInt;
public DoCallStuff(int aInt) {
this.aInt = aInt;
}
public String call() throws Exception { //*2
boolean resultOk = false;
if(aInt == 0){
resultOk = true;
} else if(aInt == 1){
while(true){ //infinite loop
System.out.println("looping....");
Thread.sleep(3000);
}
} else {
throw new Exception("Callable terminated with Exception!"); //*3
}
if(resultOk){
return "Task done.";
} else {
return "Task failed";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -