# Precompile and real time loops

**URL:** https://discourse.julialang.org/t/precompile-and-real-time-loops/102025
**Category:** New to Julia
**Tags:** question
**Created:** [July 24, 2023, 3:17pm UTC](https://discourse.julialang.org/t/precompile-and-real-time-loops/102025 "2023-07-24T15:17:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![JTriggerFish](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jtriggerfish/32/51516_2.png) [@JTriggerFish](https://discourse.julialang.org/u/JTriggerFish)
#### Post date: [July 24, 2023, 3:17pm UTC](https://discourse.julialang.org/t/precompile-and-real-time-loops/102025/1 "2023-07-24T15:17:41Z")

</div>

I’m working on a package that includes a real time loop where there is an audio thread and a a “while true” loop that waits for user input in a loop.  
When doing “using [PkgName]” in the REPL, it tries to compile it but the main() function gets called and the audio starts playing and the import never returns.  
How can avoid this ? I do want to precompile as much of the package as possible because I want to avoid pauses due to the JIT but I want the main function or at least some parts of it not to be executed.  
Code is here for reference:

> <https://github.com/JTriggerFish/InteractiveSynthPOC.jl/blob/main/src/InteractiveSynthPOC.jl>

---

<div class="post-metadata">

### Author: ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)
#### Post date: [July 24, 2023, 3:26pm UTC](https://discourse.julialang.org/t/precompile-and-real-time-loops/102025/2 "2023-07-24T15:26:11Z")

</div>

The [documentation](https://docs.julialang.org/en/v1/manual/faq/#How-do-I-check-if-the-current-file-is-being-run-as-the-main-script?-1) suggests

```julia
if abspath(PROGRAM_FILE) == @ __FILE__
    main()
end

```

---

<div class="post-metadata">

### Author: ![JTriggerFish](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jtriggerfish/32/51516_2.png) [@JTriggerFish](https://discourse.julialang.org/u/JTriggerFish)
#### Post date: [July 24, 2023, 3:37pm UTC](https://discourse.julialang.org/t/precompile-and-real-time-loops/102025/3 "2023-07-24T15:37:05Z")

</div>

Ah indeed, I just had to replace the line

main()

with the snippet you posted. Thank you very much !
