1 /*
2 * Copyright 2002-2013 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.springframework.scheduling.concurrent;
18
19 import java.util.concurrent.ThreadFactory;
20
21 import org.springframework.util.CustomizableThreadCreator;
22
23 /**
24 * Implementation of the {@link java.util.concurrent.ThreadFactory} interface,
25 * allowing for customizing the created threads (name, priority, etc).
26 *
27 * <p>See the base class {@link org.springframework.util.CustomizableThreadCreator}
28 * for details on the available configuration options.
29 *
30 * @author Juergen Hoeller
31 * @since 2.0.3
32 * @see #setThreadNamePrefix
33 * @see #setThreadPriority
34 */
35 @SuppressWarnings("serial")
36 public class CustomizableThreadFactory extends CustomizableThreadCreator implements ThreadFactory {
37
38 /**
39 * Create a new CustomizableThreadFactory with default thread name prefix.
40 */
41 public CustomizableThreadFactory() {
42 super();
43 }
44
45 /**
46 * Create a new CustomizableThreadFactory with the given thread name prefix.
47 * @param threadNamePrefix the prefix to use for the names of newly created threads
48 */
49 public CustomizableThreadFactory(String threadNamePrefix) {
50 super(threadNamePrefix);
51 }
52
53
54 @Override
55 public Thread newThread(Runnable runnable) {
56 return createThread(runnable);
57 }
58
59 }