Monday 21 November 2016

Simple Threaded demo

Here's the demo code for today's Thread Application. As you can see results below. It will be printed like below.Download



Your contribution in this blog earns you 5 sessional marks. So keep giving your inputs here. 

7 comments:

  1. Sir there is no sequence in execution of threads, how can we sort out??

    ReplyDelete
    Replies

    1. Thats how threads execute. They don't execute in sequence.

      And we will use them because We don't want the server to communicate with clients in sequence. Means it should not be like Client1 first and after that client2 and then after that client3. Instead what we want is that server serves all 3 clients at the same time. *Not in sequence*

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. sir agr 5 clients ny at a time server to text kia h to server differentiate ksy kry ga msgs ko ky kis client ko kya reply krna ....................recieve msg knsy client ka h

    ReplyDelete
    Replies
    1. We will make the clientSocket object as part of our class which is extending thread. So this mean every thread will be communicating with its own client socket.
      class MyServerApp extends Thread
      {
      Socket clientSocket;
      @override
      Void run()
      {
      }
      }

      Delete