This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Timer vs Windows preemption-any solutions?  RSS feed

 
Pawel Szczepaniak
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Guys!

I have a quite big problem.
I have developed an app that include time count, and sometimes it loses concurrency. I have manage to find the source of it, I think it is cause by preemption of the windows. I have used both java Timer’s and try different configurations and threads but the time error always occur if I start to do something else while running my developed app. On 30 minutes time count I have approximately 4,5s error (Windows XP). When I do nothing else on the computer (mining I don’t click other programs) there is no time error. The error gets quite big running on Windows 7.
If there is some kind of way to minimize preemption of the windows (As I know there is no way to stop this mechanism).
Maybe I am wrong and the time count error is caused by something else.

Thanks for any help.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your code? Ideally reduced to something that illustrates the problem?

One thing to note regarding java.util.Timer: "This class does not offer real-time guarantees: it schedules tasks using the Object.wait(long) method."
 
Pawel Szczepaniak
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I know about that note in awt timer, but I try both timer... on swing timer is the same
hear is simplified code (the error also occur during this code)



Maybe there is some kind of more occur method of time count?
I have checked an when I change the priority of my app in windows task manager priority to RealTime there is absolutely no error. Is there some way to set tis parameter permanently from java code? If not how to change it permanently from windows? I have tried:




But it doesn’t start the java app. Does somebody know any working solution?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!