Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Thread..  RSS feed

 
Akhil Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am facing some problem with the threads running in swing application.

Scenario:
I have a file which contains 20,000 records (it can be more). I am doing pagination in JTable to fetch records in chunk (100 or so, at a time).
I have a search panel, where user can enter a specific records number or a range of record numbers, based on which i repopulate the JTable with search criterias.

Now, when i keep clicking next to fetch next set of records from a file, the time keeps increasing...(when i tested with standalone code, to fetch those records from a file....time reamins same)
e.g to fetch records 0-100 it takes 219 ms.
to fetch records from 101-200 it takes 367 ms.
and so on....it goes on increasing when i go through next button used in pagination, though the number of records fetched from a file remains same, as defined by the page size constant, which i have defined as 100.

code snippets are as follows




and the panel code in which i am using this table model to populate my JTable is as follows:



Initially, when application loads, fromIndex and toIndex are set to 0 to page size defined...

On subsequent clicks of the user on next or previous buttons....i recalculate the indices and pass it to the EventTableModel through its constructor to fetch new records based on these new indices.

Code works fine....only problem is with performance....I even tried to put code related to data fetching in EventTableModel in seperate thread (as can be seen in commented line........but no luck...), i run in to execution problems when, code comes to getValueAt and GetRowCount methods of EventTableModel....I even tried to return the row count as per the page size defined initially....so that.....when a record fethcing code is run seperately.....it should atleast show some blank rows and then populate it with actual data when thread has finished its work....BUt no luck again.

CAN SOMEONE RE-TEST THE SAME SCENARIO and tell me what is wrong in my code..





Any help....or any direction in this scenario.........is highly appreciated...


Thanks and regards
Akhil
[ November 13, 2007: Message edited by: Akhil Jain ]
 
Brian Cole
Author
Ranch Hand
Posts: 949
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Akhil Jain:
Now, when i keep clicking next to fetch next set of records from a file, the time keeps increasing...(when i tested with standalone code, to fetch those records from a file....time reamins same)
e.g to fetch records 0-100 it takes 219 ms.
to fetch records from 101-200 it takes 367 ms.


So you are saying that fetching records 1000-1200 takes something like 1000ms when done from your GUI code, but when you do it with standalone code it takes only 200ms?

Do you have control over this ObjectStore code that fetches the records? How does it skip to the Nth record without having to read all the data for the previous records?
 
Akhil Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it worked fine...there was no problem in my swing code...it was the problem with the ObjectStore....i fixed it and now it works fine..

thanks for support.

regards
Akhil
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!