Linux SCHED_OTHER, SCHED_FIFO and SCHED_RR – differences

SCHED_FIFO and SCHED_RR are so called “real-time” policies. They implement the fixed-priority real-time scheduling specified by the POSIX standard. Tasks with these policies preempt every other task, which can thus easily go into starvation (if they don’t release the CPU). The difference between SCHED_FIFO and SCHED_RR is that among tasks with the same priority, SCHED_RR … Read more

Provide time zone to Spring @Scheduled?

It turned out that I could not use the @Scheduled annotation, but I implemented a work-around. In the JavaDoc of the SchedulingConfigurer it is stated that: [SchedulingConfigurer is] Typically used for setting a specific TaskScheduler bean to be used when executing scheduled tasks or for registering scheduled tasks in a programmatic fashion as opposed to … Read more

Recommended method for loading a URL via a scheduled task on Windows

As pointed out by Remus Rusanu, PowerShell would be the way to go. Here’s a simple one-liner that you can use to create a scheduled task, without needing to write a separate .ps1 file: powershell -ExecutionPolicy Bypass -Command Invoke-WebRequest ‘http://localhost/cron.aspx’ -UseBasicParsing Note that line breaks are added only for clarity in all of these command … Read more

Java thread affinity

You can’t do this in pure java. But if you really need it — you can use JNI to call native code which do the job. This is the place to start with: http://ovatman.blogspot.com/2010/02/using-java-jni-to-set-thread-affinity.html http://blog.toadhead.net/index.php/2011/01/22/cputhread-affinity-in-java/ UPD: After some thinking, I’ve decided to create my own class for this: ThreadAffinity.java It’s JNA-based, and very simple — … Read more

How to stop a Runnable scheduled for repeated execution after a certain number of executions

You can use the cancel() method on Future. From the javadocs of scheduleAtFixedRate Otherwise, the task will only terminate via cancellation or termination of the executor Here is some example code that wraps a Runnable in another that tracks the number of times the original was run, and cancels after running N times. public void … Read more

How does the OS scheduler regain control of CPU?

The OS sets up a hardware timer (Programmable interval timer or PIT) that generates an interrupt every N milliseconds. That interrupt is delivered to the kernel and user-code is interrupted. It works like any other hardware interrupt. For example your disk will force a switch to the kernel when it has completed an IO.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)