The ordering of 'synchronized(this)' and 'try&catch'?

While looking at Java's source, I have noticed that PrintStream has different ordering of 'synchronized(this)' and 'try&catch' among its method.

In flash()

public void flush() {

synchronized (this) {

try {

ensureOpen();

out.flush();

} catch (IOException x) {}}

'synchronized' comes first,

but, in write(int)

public void write(int b) {

try {

synchronized (this) {

ensureOpen();

out.write(b);

out.flush();

}

} catch (IOException x) {}

'try&catch' comes first.

Would it make any difference?...

Read More »

By: StackOverFlow - 7 days ago

Related Posts