The community forums are in BETA and closed to the public.

Why Java client library does not use classes from packagejava.util.concurrent.*?

Hello guys,

I have investigated source code of java client library and compiled version pubnub-3.7.4.jar and figured out that nothing to prevents to use java.util.concurrent.*. This package was introduced to java platform since 1.5, and pubnub-3.7.4.jar compiled with bytecode version 50(java 6)

But unfortunately, instead of using well known framework, your library intensively reinvent the wheel:

  • Manual thread creation instead of using ExecutorService and ThreadFactory. Are you shure that this behavior is possible inside JEE container with enabled security manager? Are you sure that client of your library should not has control for proccess of thread creation and task scheduling?
  • Queue implemented via synchronization arround vector. LOL! Use wait-free ConcurrentLinkedQueue!
  • One reader and one writer thread per one Pubnub instance - And what is clients like me should do in case of high traffic? I have the answer - they need to create few instances, as many as required to process traffic, but what is going on if client interested only for writing or only for reading? Always in this case one of thread(reader or writer) is not used, if I am creating 100 pubnub instances then I get 100 unnessecary threads, which consume 100Mb for thread stack, and operation system scheduler should manage 100 unnesecary threads, and garbage collector needs to scan unnsecary GC roots.
  • How to clients should perform load balancing between many pubnub instances? I pity, but there is no good answer, because each pubnub instance has own independent queue, so work stealing technic can not be implemented. But problem can be easy solved by using ExecutorService.
  • And there are many, many other questions and problems.

But not everithing is so bad, your library has many unit tests, so at the first look, job to introducing java.util.concurrent should be safely done in few days. I can rewrite it and contribute to your github repository, but I want to be sure that my pull request will be integrated to official library, because I do not want the results of my work dissapeared. Could you explain your plans about evolution of java client library? Do you have any objections to introduce java.util.concurrent into pubnub java library?

Lets go together to make Pubnub Java library better!

Thanks, - Vladimir Bukhtoyarov, Senior Java backend developer at Dinosystems, Saint-Peterburg, Russia.


Comments to this discussion are now closed!