Strumenti Utente

Strumenti Sito


lpr-b:maintermina
no way to compare when less than two revisions

Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.


lpr-b:maintermina [05/10/2007 alle 18:16 (17 anni fa)] (versione attuale) – creata Marco Danelutto
Linea 1: Linea 1:
 +<code java>
 +package threadPoolConTerminazione;
  
 +
 +public class ProvaThreadPool {
 +
 + public static void main(String[] args) {
 +
 + final int N = 8;
 + final int T = 4; 
 +
 + Repository<Integer> tasks = new Repository<Integer>();
 + Repository<Integer> results = new Repository<Integer>();
 + FunzioneSemplice funz = new FunzioneSemplice();
 + ComputerThread[] ct = new ComputerThread[T];
 +
 + Generatore generatore = new Generatore(N,tasks);
 + Stampatore<Integer> stampatore = new Stampatore<Integer>(results);
 + generatore.start();
 + stampatore.start();
 +
 + System.out.println("Creazione dei thread nel pool ");
 + for(int i=0; i<T; i++) {
 + ct[i] = new ComputerThread<Integer,Integer>(tasks, results, funz);
 + ct[i].start();
 + }
 + System.out.println("Attesa terminazione thread del pool ...");
 + for(int i=0; i<T; i++) {
 + try {
 + ct[i].join();
 + } catch (InterruptedException e) {
 + e.printStackTrace();
 + }
 + }
 + System.out.println("Tutti i thread del pool sono terminati\nTerminazione Stampatore ...");
 + stampatore.interrupt();
 + System.out.println("Terminazione main");
 + return;
 + }
 +
 +}
 +</code>
lpr-b/maintermina.txt · Ultima modifica: 05/10/2007 alle 18:16 (17 anni fa) da Marco Danelutto

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki