Skip to content
Advertisement

Tag: multithreading

Distribute Range of Numbers between each threads

Config File I have a config file above in which I have number of threads I want to use and the client instance is able to use ID range from 1 to 1000 and suppose the client threads is set at 10, so each thread would have range of 100 id’s(basically by dividing end range with thread size) that it

Synchronized keyword and static classes in java

I was reading a threading tutorial that’s originally from (I believe) the IBM developerworks site. In it they talked about the synchronized keyword and how a synchronized block of code is locked by the actual object, not the block of code itself. For instance, in the code below the authors state that even though the static class ‘Thingie’s setLastAccess method

Thread Safe Singletons in Java

The wikipedia article on Singletons mentions a few thread safe ways to implement the structure in Java. For my questions, let’s consider Singletons that have lengthy initialization procedures and are acccessed by many threads at once. Firstly, is this unmentioned method thread-safe, and if so, what does it synchronize on? Secondly, why is the following implementation thread safe AND lazy

Advertisement