Is there a Kotlin equivalent of Java’s Collections.synchronizedList ? Or is this not needed in Kotlin

If I try to use the Java List a warning message comes up “This class shouldn’t be used in Kotlin…” Java lists (and other collections) are mapped types in Kotlin. So you can use Collections.synchronizedList, and it takes and returns a Kotlin List or MutableList. OTOH, synchronizedList is rarely what you actually want: it works … Read more

Return value of assignment operator in concurrent code

I think the answer depends on the compiler. The language specifies: At run-time, the result of the assignment expression is the value of the variable after the assignment has occurred. I suppose that theoretically the value could be changed before the second (leftmost) assignment occurs. However, with Sun’s javac compiler, method1 will will turn into: … Read more

Why are two AtomicIntegers never equal?

This is partly because an AtomicInteger is not a general purpose replacement for an Integer. The java.util.concurrent.atomic package summary states: Atomic classes are not general purpose replacements for java.lang.Integer and related classes. They do not define methods such as hashCode and compareTo. (Because atomic variables are expected to be mutated, they are poor choices for … Read more

In SQL Server, how can I lock a single row in a way similar to Oracle’s “SELECT FOR UPDATE WAIT”?

You’re probably looking forwith (updlock, holdlock). This will make a select grab an exclusive lock, which is required for updates, instead of a shared lock. The holdlock hint tells SQL Server to keep the lock until the transaction ends. FROM TABLE_ITEM with (updlock, holdlock)

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)