You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: external_source_external_thread.rs
    path of file: ./repos/bevy/examples/async_tasks
    
    the code of the file until where you have to start completion: //! How to use an external thread to run an infinite task and communicate with a channel.

use bevy::prelude::*;
// Using crossbeam_channel instead of std as std `Receiver` is `!Sync`
use crossbeam_channel::{bounded, Receiver};
use rand::{rngs::StdRng, Rng, SeedableRng};
use std::time::{Duration, Instant};

fn main() {
    App::new()
        .add_event::<StreamEvent>()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .add_systems(Update, (read_stream, spawn_text, move_text))
        .run();
}

#[derive(Resource, Deref)]
struct StreamReceiver(Receiver<u32>);

#[derive(Event)]
struct 
    
fn setup(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());

    let (tx, rx) = bounded::<u32>(10);
    std::thread::spawn(move || {
        let mut rng = StdRng::seed_from_u64(19878367467713);
        loop {
            // Everything here happens in another thread
            // This is where you could connect to an external data source
            let start_time = Instant::now();
            let duration = Duration::from_secs_f32(rng.gen_range(0.0..0.2));
            while start_time.elapsed() < duration {
                // Spinning for 'duration', simulating doing hard work!
            }

            tx.send(rng.gen_range(0..2000)).unwrap();
        }
    });

    commands.insert_resource(StreamReceiver(rx));
}