Thursday, 5 September 2013

Calling multiple methods from Worker-Thread in SwingWorker (doInBackground)?

Calling multiple methods from Worker-Thread in SwingWorker (doInBackground)?

I'm new to Thread and wanted to use the SwingWorker for updating my GUI,
while another thread is analyzing some html and downloading files..
Here's my code:
protected Void doInBackground() throws Exception {
analyzeHTML();
download();
return null;
}
The whole call is failing sometimes:
SEVERE: null
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:633)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:579)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1322)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at
org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:429)
at
org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:446)
at
org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:446)
at
org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:153)
at
hanserdownloader.LinkProcessorThread.analyzeHTML(LinkProcessorThread.java:208)
at
hanserdownloader.LinkProcessorThread.doInBackground(LinkProcessorThread.java:139)
at
hanserdownloader.LinkProcessorThread.doInBackground(LinkProcessorThread.java:113)
at javax.swing.SwingWorker$1.call(SwingWorker.java:296)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at javax.swing.SwingWorker.run(SwingWorker.java:335)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
So my question is:
Are these two methods above also running in the worker-thread, when they
are called from one/doInBackground(). Should be, right?
Seems to be a dumb question, but I'm a bit unsettled, if this
timeout-error isn't really produced by some thread mess (instead of a real
http-timeout)..
Thank you for your help!

No comments:

Post a Comment