Non-interruptible thread sleeping

Is is possible to sleep a thread in such a way that's not affected by the thread being interrupted? I know when a thread is waiting to acquire a lock it's not bothered by interruptions so is there such a thing without having to sit on some objects monitor?
8 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @nikcho-kouhai! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Kyo-chan
Kyo-chan10mo ago
I guess you can check whether you slept long enough and if not, sleep what's left Couldn't you simply opt out of interrupting?
nikcho-kouhai
nikcho-kouhaiOP10mo ago
I could opt out of interrupting but that would complicate things a lot and the point isn't to sleep for some particular time period the point is to sleep for any time at all because otherwise my cpu usage goes to 50%
Kyo-chan
Kyo-chan10mo ago
Who smells X Y problem?
nikcho-kouhai
nikcho-kouhaiOP10mo ago
That could very well be the case but I would rather hold off on rewriting a bunch of stuff until after I find out whether it's at all possible although it sounds like it probably isn't
Defective
Defective10mo ago
sniff yeah, definitely Please be more specific What exactly are you trying to achieve?
nikcho-kouhai
nikcho-kouhaiOP10mo ago
Well I am making something like a video player and you know these cool sliders the video players have where you drag them and go around the video? well I need that skipping around the video to be as interactive as possible so I need to process the most recent slider move but when the slider handle is just taken and dragged across that equals a bunch of these skip requests and the way I deal with this is sleep the thread that handles the skipping for a bit at the beginning of the method and if another skip request comes I interrupt that sleeping and start processing the new one the problem is when the slider is getting dragged across the interrupt requests come to fast and the thread is basically active 100% of the time
JavaBot
JavaBot10mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server