---
title: "问题：为什么线程名称为Thread-1的线程没有被成功创建？"
author: "hoonee"
date: "2014-05-15T21:05:05Z"
tags: []
categories: ["编程语言"]
slug: "thread-1"
draft: false
lastmod: "2014-05-15T21:05:05Z"
id: 2067095
url: "https://hoonee.iteye.com/blog/2067095"
---

为什么线程名称为Thread-1的线程没有被成功创建？

package com.hoonee.javase.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
/**
 * Callable 用法举例
 * @author Hoonee
 * @mail   hoonee@163.com
 */
public class FirstCallable implements Callable<Integer>{

	@Override
	public Integer call() throws Exception {
		int i = 0;
		for(; i < 100; i++)
		{
			System.out.println(Thread.currentThread().getName() + "-" + i);
		}
		return null;
	}

	
	public static void main(String args) {
		
		FirstCallable callable = new FirstCallable();
		FutureTask<Integer> task = new FutureTask<Integer>(callable);
		
		for(int i = 0; i < 100; i++)
		{
			System.out.println(Thread.currentThread().getName() + "-" + i);
			if(i == 20)
			{
				new Thread(task,"Thread-0").start();
				//为什么线程名称为Thread-1的线程没有被成功创建
				new Thread(task,"Thread-1").start();
			}
		}
		
		try {
			System.out.println(task.get());
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (ExecutionException e) {
			e.printStackTrace();
		}
	}
}