Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.net.ServerSocket;
- import java.net.Socket;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author luis-rei
- */
- public class ServerThread extends Thread {
- private static Socket sc;
- private static ObjectOutputStream oOS;
- private static ObjectInputStream oIS;
- public ServerThread(Socket sc)
- {
- this.sc = sc;
- }
- public void interrupt()
- {
- System.out.println("[LOG Thread " + Thread.currentThread().getName() + "] Thread has been interrupted!");
- }
- @Override
- public void run() {
- try
- {
- this.oOS = new ObjectOutputStream(this.sc.getOutputStream());
- System.out.println("[LOG Thread " + Thread.currentThread().getName() + "] ObjectOutputStream criado com sucesso!");
- this.oIS = new ObjectInputStream(this.sc.getInputStream());
- System.out.println("[LOG Thread " + Thread.currentThread().getName() + "] ObjectInputStream criado com sucesso!");
- System.out.println("IP Address: " + this.oIS.readUTF());
- String test = this.oIS.readUTF();
- if(test.equals("Y"))
- {
- this.interrupt();
- this.sc.close();
- }
- }
- catch(IOException e)
- {
- System.out.println("IOException: " + e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement