• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reading file of 3300 records

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have an applet that reads data from a file into a two-dimenisional Object array. The problem is that it takes about 3-4 minutes to read all 3300 records. Data is being read from a flat file. Right now I have a nested for loop that does this, is there any way to speed up the process?
thanks,
Alex
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Alex,
i guess it can be better answered on Performance or Threads forum...
i have not uesd RandomAccess files but if that is useful in directly reading a given number of line then you can create multiple threads (say some fix number of threads) and assign responsibility of reading say 'n' records from the file to each thread and schedule it that way. each thread will also need to know the location in the 2-D array to put the data it reads.
somthing like,
total records: n
total threads: m
duty of thread-i,
1. knows the start point for reading the records from the file,
2. reads 'i' records
3. knows the array index where it is supposed to put the read in data
4. puts data in the appropriate array indices...
each thread will have to read (int)n/m records and the last thread might end up reading little more/less number of records...
i don't have clear code in my mind right now but if you can ask some guy spending more time with java threads/performance than the spouse then you might get better approach..
regards
maulin.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic