Home TechnologyProgrammingJava Subscribe to RSS

What Is Meant By Threads In Java ? How Do You Create A Network Server Application In Java?

Answer Question

1 Answer - Sort by: Date | Rating

    The thread is a small process and in Java, user can create threads in several ways. The simplest way of programming with thread in java is to take an existing class and mold it into a thread program. A good programmer do this by modifying the class so that it implements the Runnable interface, which declares the run () method.

    The run () method is required by all types of threads. The run () method restrict the code to be executed by a thread. The second way to create a thread is to write a completely separate class inherited from Java's Thread class. Because the Thread class itself implements the Runnable interface, it already restrict a run () method. The thread programming is mostly work with java network classes. In client/server model, there is one server program that supports multiple clients; it is a perfect application for threads.

    A server program has one main thread that manages the listening socket. Whenever the server socket receives a connection request from a client, the main thread makes a new thread to maintain the communications with that exceptional client. This client thread will run only as long as the client connected to the server. A server that works in this way as client, then it is known as multithreaded envoirment.
    0 0

    Virgo 

    answered 3 years ago

      More

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International