Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8536061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:34:32+00:00 2026-06-11T10:34:32+00:00

I know for ONE thread (one socket), I cannot perform read() or write() at

  • 0

I know for ONE thread (one socket), I cannot perform read() or write() at the same time, or can I?

But what if I create 2 thread and each of them handle read() and write() separately? I don’t know in low level view, will the read() and write() obtain the socket lock, so only one operation is allowed to execute at one time? Will it?

I am using Window as the platform, but also like to know is there different in Unix machine?

I ask this question because I am confused that, why we need non-blocking IO since 2 threads are able to let us read() and write() simultaneously?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:34:33+00:00Added an answer on June 11, 2026 at 10:34 am

    I know for ONE thread (one socket), I cannot perform read() or write() at the same time, or can I?

    Of course not. A thread can only call one method at a time. The question makes no sense.

    But what if I create 2 thread and each of them handle read() and write() separately? I don’t know in low level view, will the read() and write() obtain the socket lock, so only one operation is allowed to execute at one time? Will it?

    They don’t need a lock. TCP is full-duplex. You can read and write on the same socket. at the same time.

    I am using Window as the platform, but also like to know is there different in Unix machine?

    No.

    I ask this question because I am confused that, why we need non-blocking IO since 2 threads are able to let us read() and write() simultaneously?

    Make up your mind. First you asked whether it is possible, now you (correctly) say it is.

    NIO allows you to handle more than one socket in the same thread. The purpose of this is conservation of threads, for example in servers that have to handle hundreds of thousands of connections.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know one can add event listener for window.error. However when working with Iframes,
If I need to create a couple of nested DOM elements, I know one
Any one know how to apply a css propert to the a tag, but
I know this might have been asked a thousand times before, but I can't
I know the term Load Balancing can be very broad, but the subject I'm
Can a socket be closed from another thread when a send / recv on
I know one way to solve this question is to Hash the words and
I know one awkward solution for this taks will be : first use ct
This is a very very basic question and I know one way is to
I'm learning Java, and I know one of the big complaints about newbie programmers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.