Question: So I need to do a query based on the results of another query.   
Is there a way for me to set the result of a query to a variable so I can use the result of that in another query?

Example:  

{original query} --->

```
SELECT
tablea.number

FROM tablea

INNER JOIN tableb

ON tablea.name = tableb.name

WHERE tableb.zip = '11111'

```

Now I want to use this result to then do another query:

```
SELECT *

FROM tablea

WHERE number = (results of last query)

```

I think theres a way to set the first query to a variable so that that way the second one can just use the result, just not sure how. Thanks.

Answer: 
What you are doing is [specifically prohibited](http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29):

> 
> Shutdown hooks should also finish their work quickly.
> 
> 
> 

Joining random threads cannot be described as 'quick'.

Obviously those threads should close their *own* streams when they exit. If they don't exit, how will calling `join()` accomplish anything?
It is not recommended to use System.exit() as that just terminates the JVM. There are other concurrency tools like a CountDownLatch. You could even use a finally to clean up correctly on shutdown.