• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Sometimes my thread blocks ... and I don't know why !

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got this code which executes on some hardware :





pollHardwareDriver is a native method. When this method returns a value other than 0, it means that a user is interacting with a control on the hardware, but I don't think my prob occurs when this happens or in the processData method that gets called after. In fact, the log suggests the thread just stops executing and gets blocked for some reason

I've put logging in the run() method both before and after writeControlMessage gets called - I outputted "About to poll driver" and "Driver polled" every minute. I looked in the logs and these message were printed out but then just stopped. I was hoping that when the problem cropped up just the first message would print out then I could get someone to look at the native method.

The problem is then that when someone interacts with a control nothing happens - the thread is blocked for some reason.

The REFRESH_RATE is set to 1. This was initially set to 3 but someone suggested setting it to 1 so that the prob might show up quicker.

Any ideas/suggestions/remedies greatly received.

Thanks,

Michael
 
Ranch Hand
Posts: 163
1
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If `writeControlMessage()` throws an exception, your task will stop getting executed by executor service. You could catch all exceptions in your `run` of the task, and see whether you find some clue.
 
Marshal
Posts: 3708
523
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Salil - there is probably something in your writeControlMessage which is throwing an exception, maybe as a result of increasing the polling rate.

Also, this doesn't address your issue, but you could reduce the lines of code for kicking-off the periodic running of your task using a lambda:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic