Using pipedinputstream to REQUEST data from another thread
I am developping a server that will act as a database server to fetch info from a database and send it back to clients. I have made it multithreaded and ran into a wall. I know of piped streams and how you can pass the output stream to a thread and the input stream to the other and have the input stream read whatever is passed to it from the output stream. The way my server works is i have one thread that interacts with the db and has a get connection method which returns a connection. I also have a socket listener class that gets queries from clients and executes them. What i would like to do is have the listener thread REQUEST a connection from the DB thread using piped streams. Normally data is being pushed to the input stream via the output stream, as opposed to the input stream requesting data from the output stream.
I don't have code example since i have not implemented this part yet (my server only displays the query and returns an acknowledgement to the clients so far). Is what i'm trying to do possible?