1.non-static class Alinist and Patient cannot be referred within static method main()
2.PipedInputStream.connect and PipedOutputStream.connect will throw IOException
3.Thread.join() will throw InterruptedExceptionbetter to create a test() method. put all the lines now in the main() into test(). And in main() just call:
new Alinist2().test().