How I can put a lock around InputStream and release when reading is done

I want to put a Lock around Object and lock this stream. And when I am done finished reading I want to release the lock. How can I achieve this?


Do you mean?

InputStream is =
synchronized(is) { // obtains lock
    // read is
} // release lock

Its usually a good idea to use one thread to read or write to a stream, otherwise you are likely to get some confusing and random bugs. ;)

If you want to use a Lock as well

InputStream is =
Lock lockForIs = 
try {
    // read is
} finally {

You can't just lock on the InputStream, as it wouldn't prevent write access from a relevant OutputStream; you have to check the lock any time you want to write from the OutputStream.

Need Your Help

Stop animation symbol on polyline - googlemaps

javascript google-maps-api-3 overlay google-polyline

I used the animation for symbols on polylines according to this answer that was very useful:

Set day of month in calendar android

java android calendar

I'm not a frequent programmer for android and do not really understand why this happens:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.