Sean Funk wrote:Wow!
I'm walking through/debugging the code now - if I'm correct, the code doesn't actually get the post body (which is absolutely OK - I can work from there!)? It executes perfectly. There are several implementations that will take me a little time to work through that you've used here (main(String... args) for example) Good thing I have the week off, I'll be digesting this for a little bit. :-)
Could I suggest then that the main reason is that you've only thought through one
way of doing this?
And I say that without, I admit, having looked in detail at your code.
But your questions are all about "how". How do I do [this]? Why is [this] going wrong? - which suggest that you've already decided on an implementation before
you know whether it's the right
The very fact that you've decided that "multi-threading" is what you want seems like the wrong basis from which to begin a design (or a redesign).
Why do you want to multi-thread? What benefits do you think it will provide? Do you know
that it will solve the reasons for redesigning in the first place?
It's perfectly possible that you have good answers to all those questions; but unless we know what they are, all we can work with is the pile of code you submitted, and your assumption
that the "change to multi-threading" is required.
Personally, there are two things I try to avoid at all costs
when I'm programming: Reflection, and multi-threading.
The first because it seems wonderful, and usually isn't; the latter because the second you enter into a multi-threaded world you take on a whole new set of problems - namely: every gateway to every variable or action in your class becomes a potential "leak" or "anomaly" (ie, it basically doesn't behave the way you expect it to).
Secondly: multi-threaded programs are usually very
difficult to test
Databases have to deal with multi-threading because ... well ... that's what they were designed for; and it's also why they have teams
of people to deal with the results and to test every change to blue heat.
So, first question: given the above, do you still
think that multi-threading is the only solution?
Second question: Why? (and please be specific)
be the right answer, and Java provides a lot of support for it; but IMO you need to really
want to do it, and it should be as minimal as possible in all cases.
Sorry if it isn't the answer you wanted, or doesn't help; but it's something (as you may have gathered) that I feel quite strongly about.