• Post Reply Bookmark Topic Watch Topic
  • New Topic

IO error in synchronized block  RSS feed

 
Thomas Lory
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When one thread th1 is processing a synchronized block,
another thread th2 is waiting to get processed..

If 1st thread fails while processing an IO, what will happen ?

Thanks,
Lory
 
Henry Wong
author
Sheriff
Posts: 23281
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably need to clarify a bit more, as your example is very general.

However, generally, the second thread that is blocked on a lock, can't obtain the lock until the first thread releases it. And the first thread will release it when it leaves the synchronized block -- regardless of whether there is an I/O error or not.... meaning it does not matter how it leaves the block. If it leaves the block, it releases the lock.


And BTW, welcome to the ranch.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!