Skip to content

Instantly share code, notes, and snippets.

View jakubjanecek's full-sized avatar

Jakub Janeček jakubjanecek

  • Prague, Czech Republic
View GitHub Profile
val sum = collectionOfNumbers.sum
int sum = 0;
for (int n : collectionOfNumbers) {
sum += n;
}
def txn(block: => Unit): Unit = {
val transaction = new Transaction
try {
transaction.begin()
block
transaction.commit()
}
txn {
println("I am in transaction, safe and sound!")
}
Transaction t1 = new Transaction();
t1.begin();
try {
System.out.println("I am in transaction, safe and sound!");
t1.commit();
} catch (Exception ex) {
t1.rollback();
}