# preStart() question

**URL:** <https://discuss.akka.io/t/prestart-question/1343>\
**Category:** Akka Libraries\
**Created:** [June 19, 2018, 6:08pm UTC](https://discuss.akka.io/t/prestart-question/1343 "2018-06-19T18:08:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danieru](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@danieru](https://discuss.akka.io/u/danieru)\
**Post date:** [June 19, 2018, 6:08pm UTC](https://discuss.akka.io/t/prestart-question/1343/1 "2018-06-19T18:08:15Z")

</div>

When an actor starts up and preStart() is run, is it guaranteed that the actor will not receive any messages via onReceive() until the entire code block in preStart() is run?

The reason I ask is I have some business logic that has to run during initialization and just want to make sure that nothing else in the actor is happening.

---

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/ktoso/32/19_2.png) [@ktoso](https://discuss.akka.io/u/ktoso)\
**Post date:** [June 19, 2018, 6:21pm UTC](https://discuss.akka.io/t/prestart-question/1343/2 "2018-06-19T18:21:08Z")

</div>

Yes, that’s guaranteed. As the name implies “pre start” =\> “before starting doing other stuff” :-)  
If you do any async (futures in preStart though) it will not wait for them to complete ofc.

---

<div class="post-metadata">

**Author:** ![bentito](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/bentito/32/177_2.png) [@bentito](https://discuss.akka.io/u/bentito)\
**Post date:** [June 19, 2018, 6:21pm UTC](https://discuss.akka.io/t/prestart-question/1343/3 "2018-06-19T18:21:19Z")

</div>

From here: [https://doc.akka.io/docs/akka/2.5/guide/tutorial\_1.html](https://doc.akka.io/docs/akka/2.5/guide/tutorial_1.html)  
seems pretty definitive:

```auto
The Akka actor API exposes many lifecycle hooks that you can override in an actor implementation. The most commonly used are preStart() and postStop().

preStart() is invoked after the actor has started but before it processes its first message.
postStop() is invoked just before the actor stops. No messages are processed after this point.

```
