A recurring challenge in programming is accessing a shared resource concurrently. How to make sure the code doesn’t behave differently when multiple thread or operations tries to access the same property. In short, how to protect from a race condition? To build a Thread-safe data structure, we need to briefly walk through concurrency principles in […]
Custom getters and setters for fields in a class is not a new idea. We have been using them since our early days in programming. Kotlin, however, takes that concept to a more elegant level by allowing us to define getters and setters at the declaration site of our properties. The primary advantage of this […]