Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Tech > [java] Metodo join()
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
luna
.grande:maestro.

User info:
Registered: Apr 2003
Posts: 4565 (0.55 al dì)
Location: Rozzano
Corso:
Anno: Ormai finito!
Time Online: 102 Days, 14:49:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[java] Metodo join()

Ciao!!

Qualcuno saprebbe spiegarmi come si usa questo particolare metodo in java?

Mi serve perche' sto facendo un progetto che simula una rete peer to peer e quando un peer vuole terminare, deve per prima cosa controllare che non ci siano dei peer che stanno scaricando file da lui...e credo che questo join faccia su per giu' questo!ma non so come applicarlo!

pleasseee aiutatemiii :(

__________________
"Solamente il cuore ti permette di vedere chiaramente.L'essenziale e' invisibile agli occhi"
bisogna vivere "alla giornata", senza crearsi troppe aspettative. quello che viene sarà un "di più" ed è da mettere nel salvadanaio.
Sono troppo una grilla petulante :D by Nous

05-06-2006 19:53
Click Here to See the Profile for luna Click Here to See the Blog of luna Click here to Send luna a Private Message Find more posts by luna Add luna to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Hamelin
.pifferaio.magico.

User info:
Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno:
Time Online: 7 Days, 7:19:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Intendi il metodo join () della classe Thread? È semplicemente il modo in cui si impone ad un thread di attendere la terminazione di un altro thread (simile alla waitpid () in Unix per le applicazioni multi-processo in linguaggio C). Nel tuo caso, imporresti al peer di attendere la terminazione del thread che gestisce il download del file verso un altro peer... che non è esattamente quello che vuoi (credo).
La documentazione ufficiale Sun è qui.

__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."

06-06-2006 13:27
Click Here to See the Profile for Hamelin Click here to Send Hamelin a Private Message Visit Hamelin's homepage! Find more posts by Hamelin Add Hamelin to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
luna
.grande:maestro.

User info:
Registered: Apr 2003
Posts: 4565 (0.55 al dì)
Location: Rozzano
Corso:
Anno: Ormai finito!
Time Online: 102 Days, 14:49:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

no invece è proprio quello che voglio :D non far terminare il mio peer fin quando non ha finito di fornire il file a chi ha richiesto il download..peccato che non sappia proprio come implementarlo sul mio progetto :(

__________________
"Solamente il cuore ti permette di vedere chiaramente.L'essenziale e' invisibile agli occhi"
bisogna vivere "alla giornata", senza crearsi troppe aspettative. quello che viene sarà un "di più" ed è da mettere nel salvadanaio.
Sono troppo una grilla petulante :D by Nous

06-06-2006 13:33
Click Here to See the Profile for luna Click Here to See the Blog of luna Click here to Send luna a Private Message Find more posts by luna Add luna to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Hamelin
.pifferaio.magico.

User info:
Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno:
Time Online: 7 Days, 7:19:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Mah... ad ogni richiesta di download crei un nuovo thread che gestisce l'operazione. Magari memorizzi in una struttura dati (un'ArrayList, ad esempio) l'elenco dei thread/download (e li rimuovi una volta terminati). Quando poi l'utente manifesta il desiderio di chiudere il programma, iteri sulla struttura dati e fai un join per ognuno dei thread/download ancora attivi. È solo un'idea... probabilmente ce ne sono di migliori.

Comunque, ti consiglio di leggere un'introduzione al multi-threading in Java: nel capitolo corrispondente di TIJ, nel tutorial Sun o al limite qui.

__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."

06-06-2006 15:08
Click Here to See the Profile for Hamelin Click here to Send Hamelin a Private Message Visit Hamelin's homepage! Find more posts by Hamelin Add Hamelin to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
luna
.grande:maestro.

User info:
Registered: Apr 2003
Posts: 4565 (0.55 al dì)
Location: Rozzano
Corso:
Anno: Ormai finito!
Time Online: 102 Days, 14:49:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

grazie!

__________________
"Solamente il cuore ti permette di vedere chiaramente.L'essenziale e' invisibile agli occhi"
bisogna vivere "alla giornata", senza crearsi troppe aspettative. quello che viene sarà un "di più" ed è da mettere nel salvadanaio.
Sono troppo una grilla petulante :D by Nous

06-06-2006 19:23
Click Here to See the Profile for luna Click Here to See the Blog of luna Click here to Send luna a Private Message Find more posts by luna Add luna to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 02:11.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.103 seconds (39.98% PHP - 60.02% MySQL) con 25 query.