Java Code Examples for java.util.concurrent.LinkedBlockingQueue.take()

The following are Jave code examples for showing how to use take() of the java.util.concurrent.LinkedBlockingQueue class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: chromium-for-android-56-debug-video   File:   Source Code and License Vote up 6 votes
private BookmarkFolder loadBookmarks(final BookmarkId folderId) {
    final LinkedBlockingQueue<BookmarkFolder> resultQueue = new LinkedBlockingQueue<>(1);
    //A reference of BookmarkLoader is needed in binder thread to
    //prevent it from being garbage collected.
    final BookmarkLoader bookmarkLoader = new BookmarkLoader();
    ThreadUtils.runOnUiThread(new Runnable() {
        public void run() {
            bookmarkLoader.initialize(mContext, folderId, new BookmarkLoaderCallback() {
                public void onBookmarksLoaded(BookmarkFolder folder) {
    try {
        return resultQueue.take();
    } catch (InterruptedException e) {
        return null;