代码:
public class Text01 {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
QQ qq = new QQ();
// Thread.sleep(4000);
qq.setListener(new IQQListener() {
@Override
public void onResult(String result) {
// TODO Auto-generated method stub
System.out.println(result);
}
});
}
}
interface IQQListener{
public void onResult(String result);
}
class QQ{
IQQListener listener;
public QQ() {
new Thread(new Runnable() {
@Override
public void run() {
System.out.println("Run");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
listener.onResult("我是kjkjkjkllkl");
}
}).start();
}
public void setListener(IQQListener listener) {
this.listener = listener;
}
}