Here you can find the source of getThreadFactory(String name)
Parameter | Description |
---|---|
name | the name prefix of the new thread |
public static final ThreadFactory getThreadFactory(String name)
//package com.java2s; /******************************************************************************* * Copyright (c) 2016 Weasis Team and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w. ja va 2 s. c o m * Nicolas Roduit - initial API and implementation *******************************************************************************/ import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; public class Main { /** * Based on the default thread factory * * @param name * the name prefix of the new thread * @return the factory to use when creating new threads */ public static final ThreadFactory getThreadFactory(String name) { return r -> { Thread t = Executors.defaultThreadFactory().newThread(r); t.setName(name + "-" + t.getName()); //$NON-NLS-1$ return t; }; } }