Wicket sometimes makes things easier for us that we forget what's under the 
hood :)

Remember that most of your implementation is already thread safe and synced on 
the Page.
Read more about the request cycle in the free guide at:
http://wicket.apache.org/guide/guide/chapter8.html

So you want to perform a long running operation in a separate thread?
Try this post:
http://javathoughts.capesugarbird.com/2008/04/spawning-thread-for-lengthy-operation.html

Have a great day,
    Paul Bors

> On Dec 30, 2013, at 6:32 PM, eaglei22 <jchojnack...@gmail.com> wrote:
> 
> Hello, I am having an issue when using a worker thread to process a csv file. 
> I have asked the same question here:
> 
> http://stackoverflow.com/questions/20747605/requestcycle-goes-null-when-using-a-separate-thread
> 
> and I wanted to post here as I feel there are not many Wicket programmers
> there.
> 
> 
> The main issue seems to be when I process a large csv file I get a read
> error. But if I process a smaller one I do not. Here is the stack trace:
> 
>   java.io.IOException: Read error
> at java.io.FileInputStream.readBytes(Native Method)
> at java.io.FileInputStream.read(FileInputStream.java:220)
> at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
> at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
> at java.io.InputStreamReader.read(InputStreamReader.java:167)
> at java.io.BufferedReader.read1(BufferedReader.java:185)
> at java.io.BufferedReader.read(BufferedReader.java:261)
> at java.io.BufferedReader.fill(BufferedReader.java:136)
> 
>    Dec 30 13:14:31 ERROR BulkLoadPage-java.io.IOException: Read error
> at java.io.BufferedReader.readLine(BufferedReader.java:299)
> at java.io.BufferedReader.readLine(BufferedReader.java:362)
> at au.com.bytecode.opencsv.CSVReader.getNextLine(CSVReader.java:266)
> at au.com.bytecode.opencsv.CSVReader.readNext(CSVReader.java:233)
> at com..wicket.BulkLoadPage.processLine(BulkLoadPage.java:547)
> at com..wicket.BulkLoadPage.access$0(BulkLoadPage.java:532)
> at     
> 
> 
> com..wicket.BulkLoadPage$BatchLoaderProcessingThread.run(BulkLoadPage.java:1294)
> at java.lang.Thread.run(Thread.java:662)
> 
> 
> 
> I basically have a listView that is being updated by the main thread using
> AjaxSelfUpdatingTimer - set to update every 1 second. The worker thread
> which is an inner runnable class uses the methods of the main class, and
> updates the arrayList which is also stored in the main class and used by the
> listView.
> 
> I was originally getting a requestCycle error, which seemed to be resolved
> by commenting out my feedbackPanel error message inside my catch. That error
> seemed to be produced from a read error produced by the reference to the
> CSVReader. The file being read in contains many lines. I believe around 15k.
> Every line has the same data which I copied and pasted just to test a large
> file. The file seems to work fine when it is less than 2k.. so I am thinking
> maybe it is a sychronization issue or some issue with data interleaving. 
> 
> I had designed this page not knowing there would be issues with larger files
> using a thread.. there is a lot of functionality and there is no issues with
> a small file as stated.. just larger ones. The only job of the thread is to
> call a method from the main thread. That method loops through and processes
> the CSV file, and when that ends.. the thread dies. Should I be using local
> variables in the thread? Or what are some steps I can take to
> troubleshooting this error? Or is there a better way I should approach this
> to having a worker thread process results while the main thread uses a
> listView to display results. A dataView was reccommended and I will try that
> as well, but I am not sure if I can use a worker thread with that or not. 
> 
> Thank you.  
> 
> 
> 
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/MultiThreading-issues-with-Wicket-tp4663325.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to