aspose file tools*
The moose likes Threads and Synchronization and the fly likes Thread lagging issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread lagging issue" Watch "Thread lagging issue" New topic
Author

Thread lagging issue

Ife Tayo
Greenhorn

Joined: Jul 24, 2012
Posts: 5
I'm a newbie here please kindly accept if I don't get some things right this first time.

I'm currently facing some thread issues. I have two thread class; one is a Translator and the other a Loader. The translator usually finish its work first and then give the details to the Loader in other to upload the documents. Now the issue, assuming the translator has finished translating 10 files and placed them in a completed folder, it is expected of the Loader to load this 10 files. This is where its currently lagging, it is currently missing some documents and loading some. Many times it will only load 7 out of 10 and skip 3.. Not in any order just randomly.

Please any help will be appreciated. Thanks for looking into this.
Ravishanker kumar
Ranch Hand

Joined: Jul 20, 2006
Posts: 53
Try to make second thread(Loader) as non-daemon thread and call it after completion of first thread(Translator)
To make a Loader as non-daemon thread you can call setDaemon(false) on Loader.

I am not sure whether it would work in your case.
It would be better if you provide code that you have written, to find out root cause.
Ife Tayo
Greenhorn

Joined: Jul 24, 2012
Posts: 5
Ravishanker kumar wrote:Try to make second thread(Loader) as non-daemon thread and call it after completion of first thread(Translator)
To make a Loader as non-daemon thread you can call setDaemon(false) on Loader.

I am not sure whether it would work in your case.
It would be better if you provide code that you have written, to find out root cause.


Many thanks for your response.

Actually the first thread (Translator) is first called, the second thread(Loader) only get called once the Translator has finished processing the files. If thats not successful, then it'll throw an exception. I'll try to see if I can make the Loader a non-daemon thread. But I doubt it'll work in my case.

The code is not just a few lines, not sure if there are rules regarding code posting.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

If you are going to post code, please read the UseCodeTags page (that's a link). Also, you probably shouldn't post all of your code, try to create the smallest possible runnable example that accurately demonstrates what you aredoing and can reproduce the problem.

That said, some questions: how many Loader threads do you create? Are you handling and reporting exceptions? How do you know 3 aren't being loaded?


Steve
Ife Tayo
Greenhorn

Joined: Jul 24, 2012
Posts: 5
Steve Luke wrote:If you are going to post code, please read the UseCodeTags page (that's a link). Also, you probably shouldn't post all of your code, try to create the smallest possible runnable example that accurately demonstrates what you aredoing and can reproduce the problem.

That said, some questions: how many Loader threads do you create? Are you handling and reporting exceptions? How do you know 3 aren't being loaded?


Thanks Steve.

Have actually managed to resolve the issue, its working as it should now.

Many thanks once again.
Ife Tayo
Greenhorn

Joined: Jul 24, 2012
Posts: 5
Ravishanker kumar wrote:Try to make second thread(Loader) as non-daemon thread and call it after completion of first thread(Translator)
To make a Loader as non-daemon thread you can call setDaemon(false) on Loader.

I am not sure whether it would work in your case.
It would be better if you provide code that you have written, to find out root cause.


Thanks Ravishanker.

The issue has been resolved.

 
Consider Paul's rocket mass heater.
 
subject: Thread lagging issue