File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Mutiple threads on a single reqest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Mutiple threads on a single reqest" Watch "Mutiple threads on a single reqest" New topic

Mutiple threads on a single reqest

Binesh Gunaratne

Joined: May 26, 2011
Posts: 4
I'm having an issue on our weblogic server in that it seems to be spawning multiple threads for one request.

In this case we run a job that takes in a csv file and then updates some database records; to my understanding this operation should execute as one thread on weblogic.

However after about a minute or so has passed, another thread is fired where the whole operation begins from the start and we end up with about 5-6 threads that are doing the exact same operation. We have tested this issue on dev environment and can guarantee that no other user is trying to execute the operation at the same time.

Any ideas on where I should look to solve the issue? we don't attempt to spawn any threads in our code.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43342
Can you run the code from an IDE in debugging mode? That way you can follow the flow of execution.

Too difficult a question for "beginning", so I shall move it. Not sure where; let's try "JiG" first.
Walter Gabrielsen Iii
Ranch Hand

Joined: Apr 09, 2011
Posts: 158
It could be the case that the Web Browser is opening several connections to your server at the same time. I know in my Opera browser, where I can set the number of server connections, the default is 16 to a server at once. It helps my browser download several objects (scripts, images, the web page, embeded stuff, and so on) at the same time.

It could be the case that a web browser if so enabled, or if it has a web speed plug-in, if it wants access to some special pages that it sent data to, might resubmit the requested data when the browser puts in multiple connections to your server.
Binesh Gunaratne

Joined: May 26, 2011
Posts: 4
Thank you both for the reply.

@Campbell - we are unable to debug this as the the threads are being spawned by weblogic. Debug will run on it's own thread and would only help us step through our code which we know does not spawn any threads.

@Walter - I will look further into this and let you know what we find, however I was under the impression that multiple connections are only made to retrieve multiple resources? in our case we are hitting a controller eg: /uploadfile and the code just does some inserts into the db. The only other thing that I should mention is that the browser does time out when we perform this operation. However; the multiple threads start to spawn before time out occurs.
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
Trust but verify.

This is a guess: Could the logic be driven by a parameter value, for example as below:

Pat Farrell

Joined: Aug 11, 2007
Posts: 4659

Binesh Gunaratne wrote: I was under the impression that multiple connections are only made to retrieve multiple resources?

Depends on what the server returns. Any html page may have tons of resources, images, CSS files, javascript libraries, etc. The RFCs and W3C standards are old, and the idea of how many resources are "reasonable" to download at once has changed a lot faster than the standards.

Use a good debugging proxy and see how many requests are actually being made, and what is triggering them.
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
Am a beginner and here is what I learn: There is no cause without effect and there is no effect without cause.

If the issue is not triggered from the client side (browser), then it must be on the server side.

Now if it's on the server side, it can not be WLServer alone that trigger the issue on it's own.
Either the code did some thing wrong which causes exception which causes WLServer to start a new
thread but WLServer did not take the initiative, the WLServer is told/set by a configuration setting
value on the server. (Thread pooling ?)

My guess is still is around the code. Have a peer code-review.

(BTW, thanks to Pat for Fiddler 2 HTTP Debugging Proxy.
I agree. Here's the link:
subject: Mutiple threads on a single reqest
It's not a secret anymore!