Here you can find the source of runSync(final Lock lock, final Runnable task)
Parameter | Description |
---|---|
lock | lock to be used for synchronization |
task | task to run |
static final void runSync(final Lock lock, final Runnable task)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.locks.Lock; public class Main { /**/*from w w w . ja v a 2 s. com*/ * Run task synchronously on current thread using provided {@code lock} for synchronization. * <p><b>PRE-conditions:</b> non-null {@code lock}, non-null {@code task} * <br><b>POST-conditions:</b> NONE * <br><b>Side-effects:</b> task is run on current thread * <br><b>Created on:</b> <i>12:34:07 PM Mar 28, 2017</i> * * @param lock * lock to be used for synchronization * @param task * task to run */ static final void runSync(final Lock lock, final Runnable task) { try { lock.lock(); task.run(); } finally { lock.unlock(); } } }