Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
41 views

IMTester Java

This Java code defines an IMTester class that extends the Thread class. The main method creates 100 instances of IMTester and starts each thread. The run method of each thread establishes a socket connection to localhost port 7777, gets a print writer for the socket output stream, loops 100 times writing a test message to the stream including the thread name and attempt number, sleeps for 10 milliseconds each loop, and finally writes "quit" to the stream before closing the connection.

Uploaded by

hj43us
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
41 views

IMTester Java

This Java code defines an IMTester class that extends the Thread class. The main method creates 100 instances of IMTester and starts each thread. The run method of each thread establishes a socket connection to localhost port 7777, gets a print writer for the socket output stream, loops 100 times writing a test message to the stream including the thread name and attempt number, sleeps for 10 milliseconds each loop, and finally writes "quit" to the stream before closing the connection.

Uploaded by

hj43us
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 1

Archivo: /home/misan/workplace/IMTester/IMTester.

java Página 1 de 1

import java.io.*;
import java.net.*;

public class IMTester extends Thread {

public static void main(String[] args) {


for(int i=0;i<100;i++) new IMTester().start();
}
public void run() {
try {
Socket s = new Socket("localhost",7777);
PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
for(int i=0; i<100; i++) {
pw.println("Test output from client "+getName()+", attempt "+i);
sleep(10);
}
pw.println("quit");
} catch (Exception e) {}
}

You might also like