Java Reference
In-Depth Information
System . out . println ( "Idling" );
store . idle ();
} catch ( MessagingException ex ) {
ex . printStackTrace ();
return ;
}
}
}
};
Thread t = new Thread ( r );
t . start ();
} catch ( MessagingException ex ) {
ex . printStackTrace ();
}
}
}
Note that in this case it's not enough to simply install a listener. The server won't push
information to the client. The client has to contact the server. To make this happen,
Example 9-2 spawns a separate thread that periodically sends idle() commands to the
IMAP server. The server can respond to one of these when it has something to say.
Otherwise the connection is just held open indefinitely.
Now every time a message arrives in the INBOX, its subject will be logged to System.out .
Search WWH ::




Custom Search