• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread lagging issue

 
Ife Tayo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ife Tayo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic