Java Socket server-client Mode 2.0

Source: Internet
Author: User
Tags try catch

This version implements multi-threading, and the Server and client code are almost identical except for ServerSocket, and there are some problems at the end.

Harvest:

1. First multithreaded programming, sledgehammer, classes inherit the Runnable interface, write the code that requires another thread to the Run method, and start with the new Thread (this). Start ().

2. Can be sent without waiting to receive

3. In fact, quite simple, not long after writing.

Problem:

1.try catch, there are a lot of places to be forced to join, this place when writing a little bit.

2. Multithreaded programming also requires learning.

2. There are some minor problems in how to end, and the solution now is to put the buffer class in the run and start method into a class member, plus a shutdown method, which is

Receive bye and send bye all call shutdown method, there is no time to verify today.

2017-11-07 22:51:32

Java Socket server-client Mode 2.0

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.