There are five active threads in this applet.
ThreadOne is writing data to the os stream.
ThreadTwo lives in a wait/notify loop and wakes up (timeout on wait/notify)
every second to update a progress bar and statistics, using values stored in
a object (to which this thread has exclusive access).
The other threads are living in there own wait/notify loops and are not active unless noified.
problem scenerio:
On occasion - most of the time - ThreadOne rushes through the while loop writing data for a 2mb image in less
than a second and then waits for a longer time for a response.
ThreadTwo never has a chance to update the progress bar when ThreadOne rushes through the while loop, either because the
time span is too short or ThreadOne aggressively holds the cpu?
Between the while loop and waiting for a response code ThreadTwo gets a chance to upload the progress bar
which it updates to 100% as ThreadOne appears to have written all data to the stream in the while loop.
Then there is a long wait (for a response) while, i suspect, the data is actually being written to the stream or to disk.
Eventually the upload is completed and the same behavior may repeat for the next file.
The corresponding console output is (for each image where the 1657 and 1907 times indicates problematic behavior):
bufferSize: 8192, whileloopWriteTime: 40125, waitForResponseTime: 500
bufferSize: 8192, whileloopWriteTime: 31937, waitForResponseTime: 625
bufferSize: 8192, whileloopWriteTime: 1657, waitForResponseTime: 27843
bufferSize: 8192, whileloopWriteTime: 1907, waitForResponseTime: 33734
bufferSize: 8192, whileloopWriteTime: 48719, waitForResponseTime: 641
bufferSize: 8192, whileloopWriteTime: 34578, waitForResponseTime: 688
Could there be a problem with my implementation (OutStream or the backend use of O'Reilly's MultipartRequest)?
more console output normal behavior:
starting from whileloop:
ThreadOne: write file: 8192 : 8192
... etc
ThreadOne: write file: 8192 : 2351104
ThreadOne: write file: 8192 : 2359296
ThreadOne: write file: 8192 : 2367488
ThreadOne: write file: 8192 : 2375680
ThreadOne: write file: 8192 : 2383872
ThreadOne: write file: 8192 : 2392064
ThreadOne: write file: 8192 : 2400256
ThreadOne: write file: 8192 : 2408448
ThreadOne: write file: 8192 : 2416640
ThreadOne: write file: 8192 : 2424832
ThreadTwo: updating progress barandstatistics: 03A.jpg : bytes sent: 2424832
ThreadOne: write file: 8192 : 2433024
ThreadOne: write file: 8192 : 2441216
ThreadOne: write file: 8192 : 2449408
ThreadOne: write file: 8192 : 2457600
ThreadOne: write file: 8192 : 2465792
ThreadOne: write file: 8192 : 2473984
ThreadOne: write file: 8192 : 2482176
ThreadOne: write file: 8192 : 2490368
ThreadOne: write file: 8192 : 2498560
ThreadOne: write file: 8192 : 2506752
ThreadOne: write file: 8192 : 2514944
ThreadTwo: updating progress bar and statistics: 03A.jpg : bytes sent: 2514944
... etc
ThreadOne: write file: 8192 : 2621440
ThreadOne: write file: 8192 : 2629632
ThreadOne: write file: 8192 : 2637824
ThreadOne: write file: 8192 : 2646016
ThreadOne: write file: 8192 : 2654208
ThreadOne: write file: 8192 : 2662400
ThreadOne: write file: 8192 : 2670592
ThreadOne: write file: 3826 : 2674418
ThreadTwo: updating progress bar and statistics: 03A.jpg : bytes sent: 2674418
ThreadOne: write final boundry
ThreadOne: read response: (03A.jpg)
bufferSize: 8192, writeTime: 29265, responseTime: 110
ThreadOne: cleanup
============================================================================
more console output problematic behavior:
ThreadOne: write file: 8192 : 8192
... etc
ThreadOne: write file: 8192 : 2351104
ThreadOne: write file: 8192 : 2359296
ThreadOne: write file: 8192 : 2367488
ThreadOne: write file: 8192 : 2375680
ThreadOne: write file: 8192 : 2383872
ThreadOne: write file: 8192 : 2392064
ThreadOne: write file: 8192 : 2400256
ThreadOne: write file: 8192 : 2408448
ThreadOne: write file: 8192 : 2416640
ThreadOne: write file: 8192 : 2424832
ThreadOne: write file: 8192 : 2433024
ThreadOne: write file: 8192 : 2441216
ThreadOne: write file: 8192 : 2449408
ThreadOne: write file: 8192 : 2457600
ThreadOne: write file: 8192 : 2465792
ThreadOne: write file: 8192 : 2473984
ThreadOne: write file: 8192 : 2482176
ThreadOne: write file: 8192 : 2490368
ThreadOne: write file: 8192 : 2498560
ThreadOne: write file: 8192 : 2506752
ThreadOne: write file: 8192 : 2514944
ThreadOne: write file: 8192 : 2621440
ThreadOne: write file: 8192 : 2629632
ThreadOne: write file: 8192 : 2637824
ThreadOne: write file: 8192 : 2646016
ThreadOne: write file: 8192 : 2654208
ThreadOne: write file: 8192 : 2662400
ThreadOne: write file: 8192 : 2670592
ThreadOne: write file: 3826 : 2674418
ThreadTwo: updating progress bar and statistics: 04A.jpg : bytes sent: 2674418
ThreadOne: write final boundry
ThreadOne: read response: (03A.jpg)
bufferSize: 8192, writeTime: 1907, responseTime: 33734
ThreadOne: cleanup
============================================================================