FileDocCategorySizeDatePackage
InterruptibleClient.javaAPI DocExample852Sun Dec 07 10:46:00 GMT 2003javathreads.examples.ch12.example5

InterruptibleClient

public class InterruptibleClient extends InterruptibleReader

Fields Summary
Constructors Summary
public InterruptibleClient(InputStream is)

        super(is);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        Socket s = new Socket(args[0], Integer.parseInt(args[1]));
        InputStream is = s.getInputStream();
        InterruptibleClient c = new InterruptibleClient(is);
        c.start();
        System.out.println("Main thread sleeping");
        Thread.sleep(10000);
        System.out.println("Main thread woke up");
        c.interrupt();
        System.out.println("Main thread called interrupt");
    
public voidprocessData(byte[] b, int n)

        System.out.println("Got data " + new String(b, 0, n));