A project is planned. Gantt charts are drawn up. Timelines are set. They're tight up against the critical path, because including any slack time in the project plan is like planning for failure. PMs have meetings. Timelines slip. Something must be done, and the PMs form a nugget of a plan.

CORINTI

That nugget squeezes out of their meeting, and rolls downhill until it lands on some poor developer's desk.

That poor developer was Alona.

"Rex is the lead architect on this," her manager said. "And the project is about 90% complete… but even with that, they're never going to hit their timeline. So we're going to kinda do an 'all hands' thing to make sure that the project completes on time."

Alona was a junior developer, but even with that, she'd seen enough projects to know: slamming new resources onto a project in its final days never speeds up its completion. Even so, she had her orders.

Alona grabbed the code, checked the project backlog, confirmed her build environment, and then talked to the other developers. They had some warnings.

"It uses a lot of threads, and… well, the thread model is kinda weird, but Rex says it's the right way to do this."

"I don't understand what's going on with these threads, but I'm sure Rex could explain it to you."

"It's heavily CPU bound, but we're using more threads than we have cores, but Rex says we have to do it that way in order to get the performance we need."

Alona had never met Rex, but none of that sounded good. The first tasks Alona needed to grab off the backlog didn't have anything to do with the threads, so she spent a few days just writing code, until she picked up a bug which was obviously caused by a race condition.

From what she'd seen in the documentation and the code, that meant the problem had to be somewhere in MainComputationThread. She wasn't sure where it was defined, so she just did a quick search for the term class MainComputationThread.

It returned twenty hits. There was no class called MainComputationThread, though there was an interface. There were also classes which implemented that interface, named things like MainComputationThread1 and MainComputationThread17. A quick diff showed that all twenty of the MainComputationThreadn classes were 1,243 lines of perfectly identical code.

They were also all implemented as singletons.

Alona had never met Rex, and didn't want to, but she needed to send him an email and ask: "Why?"

Threading is a pretty advanced programming topic, so I put together an easy to use framework for writing threaded code, so that junior developers can use it. Just use it. -Rex

[Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!