HMRC rule change set to catch-out landlords: Thousands will soon need to report income and expenses every three months
Private investigator reveals the unlikely phone app that can expose your cheating partner
Ryan Reynolds mercilessly mocked by fans over awkward fake tan fail: 'Why is he so orange?'
From raucous street celebrations to those waiting to hear if loved ones had survived - the story of VE Day through the eyes of ordinary Britons
A Ruby Celebration! Prince William and Princess Kate are all smiles as they bump into comedian on wedding anniversary trip
CodeSOD: Pulling at the Start of a Thread
For testing networking systems, load simulators are useful: send a bunch of realistic looking traffic and see what happens as you increase the amount of sent traffic. These sorts of simulators often rely on being heavily multithreaded, since one computer can, if pushed, generate a lot of network traffic.
Thus, when Jonas inherited a heavily multithreaded system for simulating load, that wasn't a surprise. The surprise was that the developer responsible for it didn't really understand threading in Java. Probably in other languages too, but in this case, Java was what they were using.
public void startTraffic() { Configuration.instance.inititiateStatistics(); Statistics.instance.addStatisticListener(gui); if (t != null) { if (t.isAlive()) { t.destroy(); } } t = new Thread(this); t.start(); }Look, this is not a good way to manage threads in Java. I don't know if I'd call it a WTF, but it's very much a "baby's first threading" approach. There are better abstractions around threads that would avoid the need to manage thread instances directly. I certainly don't love situations where a Runnable also manages its own thread instance.
This is almost certainly a race condition, but I don't know if this function is called from multiple threads (but I suspect it might be).
But what's more interesting is where this code gets called. You see, starting a thread could trigger an exception, so you need to handle that:
public void run() { while (true) { try { loaderMain.startTraffic(); break; } catch (Exception e) { System.out.println("Exception in main loader thread!"); e.printStackTrace(); } } }Inside of an infinite loop, we try to start traffic. If we succeed, we break out of the loop. If we fail, well, we try and try again and again and again and again and again and again…
Jonas writes:
Since I'm the only one that dares to wade through the opaque mess of code that somehow, against all odds, manages to work most of the time, I get to fix it whenever it presents strange behavior.
I suspect it's going to present much more strange behavior in the future.
Spain-Portugal blackouts will happen 'more and more' as Europe continues push for Net Zero, PETER HITCHENS tells SARAH vine in provocative new Mail podcast
KDE 3 lives to fight another day as Trinity Desktop 14.1.4 hits the shelves
The long-running fork of KDE 3 has dropped its latest update: Trinity Desktop Environment R14.1.4, now with better distro support and a fresh coat of code. Not bad for a project still chugging along 15 years after KDE itself moved on.…
King Charles's bond with his cousin Lady Sarah Chatto: The pair share a talent and passion for painting and the arts
We've found a leasehold flat to buy: Should the inflation-linked £500 ground rent put us off?
Energy watchdog makes 'contingency plans' for households left with RTS meters after switch-off next month
Start-up Myne wants you to buy a share of a holiday home with strangers
My husband and I were both widowed: Can we use our late spouses' inheritance tax allowances?
Asda issues urgent food product recall warning over chicken
Trump reveals new details about 'historic' face-to-face conversation with Zelensky ahead of the Pope's funeral
Now Unions reject Ed's Green lunacy: Unite warns Labour's Net Zero plan will become 'millstone' as No.10 refuses to guarantee Miliband will keep his job
Apple Must Halt Non-App Store Sales Commissions, Judge Says
Read more of this story at Slashdot.
Trump insiders call Steve Witkoff a 'bumbling f**** idiot' after special envoy meets alone with Putin
Samsung customers buying now to avoid future tariffs – and may slow purchases once they arrive
Samsung yesterday posted results a little better than it forecast, and attributed some of its record revenue and strong profit to customers rushing to buy kit before the USA raises tariffs on imports.…