addMessageCountListener为什么不好用?

极峰 05-04-22

class TestListener extends Thread{
public void run() {
try {
Properties props = new Properties();
props.put("mail.smtp.host", "");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("pop3");
store.connect("","", "");

Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
folder.addMessageCountListener(new MessageCountListener() {
public void messagesAdded(MessageCountEvent e) {
System.out.println( "new message!" );
}
public void messagesRemoved(MessageCountEvent e) {
System.out.println( "message deleted!" );
}
} );

//for(int i=0;i<20;i++){
//System.out.println(folder.getMessageCount());
//this.sleep(1000);
//}
//folder.close(true);
//store.close();

} catch ( Exception e ) {}
}

public class TestYahooServer {
Authenticator aut = null;
public static void main(String[] args) {
TestListener testListener = new TestListener();
testListener.start();


}
受到信邮件时,为什么不能促发?