If the output stream is shared, then no.  It's buffered internally.

So at small scale, it'll look safe because the whole output is one buffer or the order was OK. But beyond that, the buffered flushes will be interleaved and buffer boundaries are based on characters, not logical unit of the RDF output.

Parallel writing to a shared OutputStream is a bad idea.

What's the use case you have for a shared output stream?

    Andy

On 26/11/17 01:40, Zak Mc Kracken wrote:
Hi all,

as per subject, is this operation (seen at https://jena.apache.org/documentation/io/streaming-io.html) thread-safe?

StreamRDFWriter.write(output, model.getGraph(), lang);

ie, can it be run by multiple threads in parallel, assuming each spawns its own Model instance and invokes the operation above at their end, when the model is complete?

Will the write() above manage the concurrent access to the output stream?

At which level? The triple, some sort of block, or the entire operation/graph? (The latter case implying there aren't benefits from this kind of parallelism).

From the first tests I've done, it seems it's thread-safe, but I don't get the details.

Thank you in advance,

Marco.



Reply via email to