# How to deal with long running loops that cannot be offloaded to activities

**URL:** <https://community.temporal.io/t/how-to-deal-with-long-running-loops-that-cannot-be-offloaded-to-activities/6135>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [October 4, 2022, 10:20am UTC](https://community.temporal.io/t/how-to-deal-with-long-running-loops-that-cannot-be-offloaded-to-activities/6135 "2022-10-04T10:20:45Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [October 4, 2022, 4:25pm UTC](https://community.temporal.io/t/how-to-deal-with-long-running-loops-that-cannot-be-offloaded-to-activities/6135/2 "2022-10-04T16:25:46Z")

</div>

> I’ve had issues passing the `Workbook` instance from Workflow to Activity.

Are you creating `Workbook` in workflow code? You could offload its creation to activity and would not have to pass it in as input.

> Is there any way to pass non serializable classes to activities?

You can pass them as input to activity impl constructor when you register activity with worker. You could write a custom data converter for your type if you need to pass it as input (by default it would need to be serializable to json using jackson).

Once you parse the workbook do you iterate through each entry and perform actions? If so you might want to use “iterator workflow pattern” mentioned in [this](https://community.temporal.io/t/design-patterns/3200/4) forum post.

---

_[View the full topic](https://community.temporal.io/t/how-to-deal-with-long-running-loops-that-cannot-be-offloaded-to-activities/6135)._
