lezione2.multithread.server
Class ServerThread

java.lang.Object
  extended by java.lang.Thread
      extended by lezione2.multithread.server.ServerThread
All Implemented Interfaces:
java.lang.Runnable

public class ServerThread
extends java.lang.Thread


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private static int counter
          Contatore dei thread server avviati.
private  int id
          ID del thread corrente.
private  java.io.BufferedReader in
          BufferedReader creato dal Socket.
private  java.io.PrintWriter out
          PrintWriter creato dal Socket.
private  java.net.Socket socket
          Socket usato dal Thread.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ServerThread(java.net.Socket s)
          Costruttore del Thread.
 
Method Summary
 void run()
          Attività del Thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

counter

private static int counter
Contatore dei thread server avviati.


id

private int id
ID del thread corrente.


socket

private java.net.Socket socket
Socket usato dal Thread.


in

private java.io.BufferedReader in
BufferedReader creato dal Socket.


out

private java.io.PrintWriter out
PrintWriter creato dal Socket.

Constructor Detail

ServerThread

public ServerThread(java.net.Socket s)
             throws java.io.IOException
Costruttore del Thread. Crea i flussi dati ed avvia l'attività del Thread.

Parameters:
s - la connessione con il client
Throws:
java.io.IOException
Method Detail

run

public void run()
Attività del Thread. Riceve messaggi dal client e li reinvia indietro finché non riceve la stringa "END".

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread
See Also:
Thread