Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package examples;
 
 import org.mapdb.*;
 
 import java.util.Map;

Demonstrates easier way to execute concurrent transactions.
 
public class Transactions2 {
    public static void main(String[] args) {
        TxMaker txMaker = DBMaker.newMemoryDB().makeTxMaker();
        // Execute transaction within single block.
        txMaker.execute(new TxBlock(){
            @Override public void tx(DB dbthrows TxRollbackException {
                Map m = db.getHashMap("test");
                m.put("test","test");
            }
        });
        //show result of block execution
        DB tx1 = txMaker.makeTx();
        Object val = tx1.getHashMap("test").get("test");
        ..println(val);
        tx1.close();
        txMaker.close();
    }
New to GrepCode? Check out our FAQ X