Results 1 to 4 of 4
- 07-16-2011, 08:43 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 2
- Rep Power
- 0
how to reduce the thread processing time
i'm face issue that i have 2 thread pool queue in which the 1st thread queue has requests (1st job creating a object A and 2rd job is deleting the same object created before ).
But at end of the processing of job in thread pool 1 we are creating a job in thread pool 2 with passing object as argument.
problem is after creating the job in 2rd thread pool, my 1st queue is started processing the 2rd job (i.e deletion of object). at that time the 2rd thread pool is processing the object created by 1st job. so that i getting some errors.
i can't create a lock on the object since it is complex object which has several shared sub class object by other threads.
can any one help how reduce the time of processing in 2rd thread pool or to make some wait for 1st thread pool
i mean some effective steps or best practices to reduce the time of processing.
- 07-16-2011, 08:57 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Is the class thread safe? I am trying to understand your problem but having a bit of trouble. Is the problem that the deleting pool is deleting an object that pool 1 is working on?
- 07-16-2011, 09:09 AM #3
Member
- Join Date
- Jul 2011
- Posts
- 2
- Rep Power
- 0
i don't exactly but i hope Class is not a thread safe...
my problem exactly is
i have cart table where we maintain the list of item details (unique cart identifier for each item)
when user check out the item ,a thread will pick the job (i.e creation of row in cart table and creation of item object then creation job to other pool for xml/db processing).
my issue is when user check out a item and delete the item with small gap (20 sec) . pool1 is creating the row in Cart table and creating the object and passing job to pool2 for xml processing ,during the time deletion job in pool 1 is started deleted the row in cart table . As a result during processing job in pool2 i'm validating the whether row exist or not and getting the error.
any suggestion to solve this issue....
- 07-16-2011, 09:15 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
There are definitely others here who may have much better advice(admittedly my thread experience is purely theoretical), however; it seems like the problem really comes from multiple threads making modifications to one object which causes inconsistencies. The item is being removed while another thread is working on it. It may require something as in depth as making the class thread safe so that the deletion cannot happen while another thread is working with the object.
There may also be some type of data structure which may be helpful to only allow one thread at a time to process information. I really hope someone will correct me if I am wrong.
Similar Threads
-
Time and Thread
By bmvasakan in forum Threads and SynchronizationReplies: 1Last Post: 09-19-2010, 04:51 PM -
need help with low priority thread to display time
By vkokaram in forum New To JavaReplies: 6Last Post: 07-19-2010, 01:10 AM -
how to reduce the thread sleep time and wake up the thread
By baktha.thalapathy in forum Threads and SynchronizationReplies: 2Last Post: 06-24-2010, 07:36 PM -
Running thread a second time
By Fleur in forum New To JavaReplies: 18Last Post: 11-17-2009, 12:57 PM -
Compile time Annotation Processing - Maven build problem
By Milesy in forum Advanced JavaReplies: 0Last Post: 07-09-2009, 11:11 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks