austinpower Posted April 21, 2007 Share Posted April 21, 2007 Salut, j'ai une classe Interruption qui est censé afficher un message lorsque je fais Ctrl-C dans le Serveur mais ça n'affiche rien : import java.awt.*; public class Interruption { public Interruption (Serveur srv) { Runtime.getRuntime ().addShutdownHook(new MonShutdownHook (srv)); } } class MonShutdownHook extends Thread { private Serveur srv; public MonShutdownHook(Serveur srv) { this.srv = srv; } public void run () { System.out.println ("sortie du serveur"); } } Dans la classe Serveur, j'ai le main suivant : public static void main(String[] args) { Integer port = Integer.parseInt(args[0]); Serveur srv = new Serveur(port); new Interruption(srv); } } ESt-ce que quelqu'un pourrait m'indiquer comment modifier le code pour que ça focntionne. Merci Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.