OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AsyncIOExample.SampleAsyncFunction


Hi,

I'm confused by lines 119-122 in https://github.com/lamber-ken/flink/blob/master/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/async/AsyncIOExample.java

Why is counter non-static, but executorService and random - static?

It's not clear to me whether open() can be called more than once on a given object, and thus it's not clear whether the intent is to count the number of open's for every object (the current code). Or we really need to make counter static - to count the number of objects that share executorService and random?..

Having executorService and random as static, but counter as instance-specific will not work when someone creates a second instance of SampleAsyncFunction. In second SampleAsyncFunction the counter will be 0 and we will re-intialize static executorService and random, thus interfering with the first SampleAsyncFunction object.

Thanks,
Alex