001/*
002 * Copyright 2002-2013 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.scheduling.concurrent;
018
019import java.util.concurrent.ThreadFactory;
020
021import org.springframework.util.CustomizableThreadCreator;
022
023/**
024 * Implementation of the {@link java.util.concurrent.ThreadFactory} interface,
025 * allowing for customizing the created threads (name, priority, etc).
026 *
027 * <p>See the base class {@link org.springframework.util.CustomizableThreadCreator}
028 * for details on the available configuration options.
029 *
030 * @author Juergen Hoeller
031 * @since 2.0.3
032 * @see #setThreadNamePrefix
033 * @see #setThreadPriority
034 */
035@SuppressWarnings("serial")
036public class CustomizableThreadFactory extends CustomizableThreadCreator implements ThreadFactory {
037
038        /**
039         * Create a new CustomizableThreadFactory with default thread name prefix.
040         */
041        public CustomizableThreadFactory() {
042                super();
043        }
044
045        /**
046         * Create a new CustomizableThreadFactory with the given thread name prefix.
047         * @param threadNamePrefix the prefix to use for the names of newly created threads
048         */
049        public CustomizableThreadFactory(String threadNamePrefix) {
050                super(threadNamePrefix);
051        }
052
053
054        @Override
055        public Thread newThread(Runnable runnable) {
056                return createThread(runnable);
057        }
058
059}