Here you can find the source of convert(Runnable runnable, T result)
Parameter | Description |
---|---|
runnable | the Runnable to convert |
result | the result the returned Callable shall return |
T | the type of result |
static <T> Callable<T> convert(Runnable runnable, T result)
//package com.java2s; /*/*w w w .ja v a2s .co m*/ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This file is part of SequentialExecutorService. * * SequentialExecutorService contains non-parallel implementations * for Java's ExecutorService and ScheduledExecutorService. * Copyright (C) 2015 Matthias Johannes Reimchen * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.concurrent.Callable; public class Main { /** * Converts the specified {@link Runnable} to a {@link Callable} returning * the specified result. * * @param runnable the Runnable to convert * @param result the result the returned Callable shall return * @param <T> the type of result * @return a Callable calling runnable and returning result */ static <T> Callable<T> convert(Runnable runnable, T result) { return () -> { runnable.run(); return result; }; } }