package com.join;
/*
题目: 人们在火车站的售票窗口排队买火车票
1. 北京西站开门
2. 打开售票窗口
3. 北京西站有10张去长沙的票
4. 打开2个售票窗口,
5 假设每个售票窗口每隔1秒钟买完一张票
1. 根据 名词 找类
人们(Person), 火车站(Station),火车票(Ticket) , 售票窗口e 是火车站的线程
*/
import java.util.*;
public class TestJoin
{
public static void main(String[] args)
{
View view=new View();
}
}
class View
{
private String[] listView;
public View()
{
Thread t=new Thread(new DownloadThread());
t.start();
try
{
t.join();
} catch (InterruptedException e)
{
e.printStackTrace();
}
for(String str:listView)
{
System.out.println(str);
}
}
public String[] getListView()
{
return listView;
}
class DownloadThread implements Runnable
{
@Override
public void run()
{
try
{
String[] countrys={"北京","上海","天津","重庆","广州","深圳","武汉"};
listView=new String[countrys.length];
for(int i=0;i
{
listView[i]=countrys[i];
Thread.sleep(1000);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}