Results 1 to 4 of 4
  1. #1
    chnaveen is offline Member
    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Default 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.

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    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?

  3. #3
    chnaveen is offline Member
    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Default

    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....

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    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

  1. Time and Thread
    By bmvasakan in forum Threads and Synchronization
    Replies: 1
    Last Post: 09-19-2010, 05:51 PM
  2. need help with low priority thread to display time
    By vkokaram in forum New To Java
    Replies: 6
    Last Post: 07-19-2010, 02:10 AM
  3. how to reduce the thread sleep time and wake up the thread
    By baktha.thalapathy in forum Threads and Synchronization
    Replies: 2
    Last Post: 06-24-2010, 08:36 PM
  4. Running thread a second time
    By Fleur in forum New To Java
    Replies: 18
    Last Post: 11-17-2009, 01:57 PM
  5. Replies: 0
    Last Post: 07-09-2009, 12:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •