Solved

Question about socket/Thread programming...

Posted on 2002-03-08
3
197 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

828 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