In an example of working with JDBC in Scala, there is a following code:
this.synchronized {
if (!driverLoaded) loadDriver()
}
Why this.synchronized
instead of just synchronized
?
In an example of working with JDBC in Scala, there is a following code:
this.synchronized {
if (!driverLoaded) loadDriver()
}
Why this.synchronized
instead of just synchronized
?
In scala
synchronized
is not a keyword, as in java.It is in fact a member of
AnyRef
, which is scala equivalent for java'sObject
.So to answer your question, you can either use
synchronized
orthis.synchronized
, just as you can dotoString
orthis.toString
.