<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.StileMessaggioDiPostaElettronica17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:70.85pt 2.0cm 2.0cm 2.0cm;}
div.Section1
        {page:Section1;}
/* List Definitions */
@list l0
        {mso-list-id:2094087609;
        mso-list-type:hybrid;
        mso-list-template-ids:986611012 68157441 68157443 68157445 68157441 68157443 68157445 68157441 68157443 68157445;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:71.4pt;
        mso-level-number-position:left;
        margin-left:71.4pt;
        text-indent:-18.0pt;
        font-family:Symbol;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
</style>
</head>
<body lang=IT link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Ciao a tutti, <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>sto scrivendo un server multithreading in <b><span
style='font-weight:bold'>java</span></b>…<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>La comunicazione fra client e server avviene tramite socket,
ma quando il server è in:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font><b><font size=2 face=Arial><span
lang=EN-GB style='font-size:10.0pt;font-family:Arial;font-weight:bold'>while(true)<o:p></o:p></span></font></b></p>
<p class=MsoNormal><b><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-weight:bold'> { <o:p></o:p></span></font></b></p>
<p class=MsoNormal><b><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-weight:bold'> if(statoServer==false){break;} <o:p></o:p></span></font></b></p>
<p class=MsoNormal><b><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-weight:bold'> <o:p></o:p></span></font></b></p>
<p class=MsoNormal><b><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-weight:bold'> </span></font></b><b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial;font-weight:
bold'>port = serverSocket.accept();<o:p></o:p></span></font></b></p>
<p class=MsoNormal><b><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-weight:bold'> scrivi("\n"+port+"
si è connesso al Server Messenger");<o:p></o:p></span></font></b></p>
<p class=MsoNormal><b><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-weight:bold'> <o:p></o:p></span></font></b></p>
<p class=MsoNormal><b><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-weight:bold'> </span></font></b><b><font
size=2 face=Arial><span lang=EN-GB style='font-size:10.0pt;font-family:Arial;
font-weight:bold'>serverThreads serverThread = new serverThreads(port);<o:p></o:p></span></font></b></p>
<p class=MsoNormal><b><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-weight:bold'> </span></font></b><b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial;font-weight:
bold'>serverThread.start(); <o:p></o:p></span></font></b></p>
<p class=MsoNormal><b><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-weight:bold'> }<o:p></o:p></span></font></b></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Mi si pianta tutto: il ciclo è normale perché sarebbe una
sorta di demone, ma sull’istruzione <b><span style='font-weight:bold'>port
= serverSocket.accept(); </span></b>(che attende la connessione del client) mi
si bloccano tutti i Listener delle finestre e dei bottoni. Il bello è che l’applicazione
riesegue il ciclo dopo la connessione del client e riesce a gestirli
perfettamente.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Tirando le somme il server:<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:71.4pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><font
size=2 face=Symbol><span style='font-size:10.0pt;font-family:Symbol'><span
style='mso-list:Ignore'>·<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>
</span></font></span></span></font><![endif]><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>funziona benissimo per quanto
riguarda i socket<b><span style='font-weight:bold'><o:p></o:p></span></b></span></font></p>
<p class=MsoNormal style='margin-left:71.4pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><font
size=2 face=Symbol><span style='font-size:10.0pt;font-family:Symbol'><span
style='mso-list:Ignore'>·<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>
</span></font></span></span></font><![endif]><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>si impallano i listener mentre
attende i client (la cosa continua anche dopo la connessione dei client)<b><span
style='font-weight:bold'><o:p></o:p></span></b></span></font></p>
<p class=MsoNormal style='margin-left:53.4pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:53.4pt'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal align=center style='margin-left:53.4pt;text-align:center'><b><font
size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:red;font-weight:bold'>QUALCUNO SA DARMI UNA MANO A TROVARE UNA SOLUZIONE
???<o:p></o:p></span></font></b></p>
<p class=MsoNormal align=center style='margin-left:53.4pt;text-align:center'><b><font
size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:red;font-weight:bold'><o:p> </o:p></span></font></b></p>
<p class=MsoNormal align=center style='margin-left:53.4pt;text-align:center'><b><font
size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:black;font-weight:bold'> Grazie 1000, st3f4n0 [:- )))<o:p></o:p></span></font></b></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
</div>
</body>
</html>