val generator = new ThreadLocalRandomGenerator(new MersenneTwister())
val outputStream = new ByteArrayOutputStream(512)
val out = new ObjectOutputStream(outputStream)
try {
out.writeObject(generator)
outputStream.toByteArray
} catch {
case ex: IOException => throw new SerializationException(ex)
} finally {
if (out != null) out.close()
}
Below code:
throws exception:
ThreadLocalRandomGenerator
has value that is not serializabled (ThreadLocal
)