//简单线程的编写
package com.sts.bean.bank;
public class ThreadForContract {
public ThreadForContract() {
new ThreadForContractLink().start();
}
}
class ThreadForContractLink extends Thread {
public void run() {
while (true) {
System.out.println(111111);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
//
例子二:
package com.sts.bean.bank;
public class ThreadForContract extends Thread {
int i = 0;
public void run() {
BankInterfaceABCImpl bankABC=null;
while (true) {
bankABC = new BankInterfaceABCImpl();
bankABC.testContact();
System.out.println("线程执行" + ++i);
try {
Thread.sleep(1000 * 60 * 5);// 休眠五分钟
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
/**
* @param args
*/
public static void main(String[] args) {
new ThreadForContract().start();
}
}