Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Concurrency issues #4
Comments
|
Hi, Thanks for taking such a close look at the code. 2013/9/21 Peter Vahlstrup notifications@github.com
Switching to a ConcurrentHashMap would prevent the possibility of seeing an We should update the class documentation to clarify the intended use of the
We should document make the intended use of the class clear in the class
This is indeed a bug. Nice catch! Sekhar C. Ramakrishnan cramakrishnan@acm.org |
|
Happy to help :)
Agreed, sorry for vague formulation
Even though it shouldn't be mutated in another thread there will (could) still be visibility issues if the setters and getters are not synchronized or the fields are not final. That is if the object crossed thread boundaries (on multi-core processors). the Java Memory Model describes this: http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.5-110 |
This should make this thread-safe as long as startListening() and stopListening() are only called from a single thread. Takes care of part of issue hoijui#4
Hi there, nice little API :-)
It has some concurrency issues though which needs attention, I will be happy to give some pointers if the project is still active. E.g.
OSCPacketDispatcher:
You need to use a ConcurrentHashMap for this to be thread safe, if you where to add a listener after OSCPortIn has started receiving messages there could be visibility issues of the newly added listener and ConcurrentModificationExceptions could occur
OSCMessage:
is not Immutable and therefore not thread safe. This can cause issues with visibility when crossing thread boundaries
OSCPortIn:
The listening flag will be accessed by multiple threads and is not currently thread safe. Should be changed to volatile or accessed In thread safe manner. If not this could cause visibility issues and in worst case it will never stop running because it want see the state change of the listening flag.
.... More issues....