ciao!

ho una applicazione console, nella quale vorrei fare un controllo a tempo.
ogni tot di minuti (anche se per i test ho messo in secondi), vorrei che venisse controllata la memoria occupata, e in caso lanciare il Garbage Collector.

per adesso nel main ho fatto così:
codice:
    public static void main(String[] args) throws IOException {
        final HttpServer server = startServer();

        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                Runtime runtime = Runtime.getRuntime();
                long memory = runtime.totalMemory() - runtime.freeMemory();
                System.out.println("MB usati: " + memory / MEGABYTE);
                // ECCETERA
            }

        }, 5000);

        System.out.println(String.format("Jersey app started with WADL available at %sapplication.wadl\nHit enter to stop it...", BASE_URI));
        System.in.read();
        server.shutdownNow();
    }
ma il timer viene eseguito una sola volta.
inoltre non ho neanche ben capito se questo viene eseguito in un altro thread, o no.
mi date qualche delucidazione per favore??