Solved

Question about socket/Thread programming...

Posted on 2002-03-08
3
201 Views
Last Modified: 2010-03-31
Hi Guys,

  If a thread calls a blocking socket.read(...), is it possible for another thread to wake up the blocking thread, so socket.read(...) return immediately


(2nd question: Is there any non-blocking socket.read(...)?)
stephen
0
Comment
Question by:zollen
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 6851713
Q1. Not that I'm aware of.

Q2. 1.4 added support for non-blocking I/O:
http://java.sun.com/j2se/1.4/docs/guide/nio/
There's also a 3rd party libraries:
http://www.purpletech.com/code.jsp
http://www.cs.berkeley.edu/~mdw/proj/java-nbio/
0
 
LVL 5

Expert Comment

by:nebeker
ID: 6852367
As an alternative to a non-blocking read, you can call "available()" to see if any data is there, before you commit to calling read().
0
 
LVL 92

Expert Comment

by:objects
ID: 6855089
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java: anonymous class 4 37
web project error add remove 1 49
Java List 4 32
Java Inheritance super keyword use 8 32
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question