Note that there are some explanatory texts on larger screens.

plurals
  1. USChad N B
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. COIf there even were a way to invoke it, how would you know if the abstract method was implemented? A class must implement all abstract methods before it can be instantiated, but for a static method, you DON'T instantiate the class. So how do you know in the first place if it is even a valid call? In Delphi, for example, you can create static abstract methods, but you can also get exceptions at runtime when you call such a method. I prefer a compile time error to a runtime error always. Like I said, it seems limiting coming from another language, but Java is trying to help you with good design.
      singulars
    2. COAs with many things in Java, coming from another language it seems like a limitation, but later you realize it is something you shouldn't do anyway. For example, in Leo's comment, if you need to know the child class in the inherited constructor, that is a blatant violation of basic OOP principles. Also, how do you propose such a method would be invoked? To invoke a static method you need the class name. Using the base class name, how do you know what subclass you intended? Yet if do you know the subclass, it didn't need to be abstract to begin with. Show syntax how this would even work.
      singulars
    3. CO...cont'd: System.nanoTime() may not be 100% accurate or consistent across cores. Anyway if you poll() a null often it means the queue is usually empty, so using multithreading is just overhead; do it on one thread and get 0 latency. Other idea: Haven't checked the implementation of poll but maybe try some other signaling mechanism. Try AtomicBoolean. In the producer use .set(true). In the consumer, poll() only if .getAndSet(false) returns true. But be VERY careful to avoid a race condition--make sure the queue is empty before the next call to getAndSet--it may have more than 1 item waiting.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload