'quebec city''reginaclass tempgetter(thread)def __init__(selfcity)super(__init__(self city city def run(self)url_template ''weather? ={},ca&units=metric'response urlopen(url_template format(self city)data json loads(response read(decode()self temperature data['main']['temp'threads [tempgetter(cfor in citiesstart time time(for thread in threadsthread start(for thread in threadsthread join(for thread in threadsprint"it is { temperature }degc in { city}format(thread)print"got {temps in {secondsformatlen(threads)time time(start)this code constructs threads before starting them notice how we can override the constructor to pass them into the thread objectremembering to call super to ensure the thread is properly initialized pay attention to thisthe new thread isn' running yetso the __init__ method is still executing from inside the main thread data we construct in one thread is accessible from other running threads after the threads have been startedwe loop over them againcalling the join(method on each this method essentially says "wait for the thread to complete before doing anythingwe call this ten times in sequencethe for loop won' exit until all ten threads have completed