R
RVic
if (null != response) {
I haev an output stream passed to a thread wherein I wish to write to
the outputstream, but have anyone else locked out from writing to it
while the particular handed-off-to thread writes to it.
I am a little unsure about using ReentrantLock to do this. In my code
below, which compiles (so what!) can anyone tell if I am using it
correctly or incorrectly or what I might have that's incorrect or
missing? Thanks, Rvince
ReentrantLock lockObject = new ReentrantLock(false);
try {
lockObject.lock();
output.write(merchLinklengthBytes(response));
output.write(headerControl);
output.write(response.getBytes());
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (null != lockObject) {
lockObject.unlock();
}
}
}
I haev an output stream passed to a thread wherein I wish to write to
the outputstream, but have anyone else locked out from writing to it
while the particular handed-off-to thread writes to it.
I am a little unsure about using ReentrantLock to do this. In my code
below, which compiles (so what!) can anyone tell if I am using it
correctly or incorrectly or what I might have that's incorrect or
missing? Thanks, Rvince
ReentrantLock lockObject = new ReentrantLock(false);
try {
lockObject.lock();
output.write(merchLinklengthBytes(response));
output.write(headerControl);
output.write(response.getBytes());
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (null != lockObject) {
lockObject.unlock();
}
}
}