# Write Generation Policy - Multi threaded application

**URL:** <https://discuss.aerospike.com/t/write-generation-policy-multi-threaded-application/8339>\
**Category:** General Discussion\
**Created:** [March 26, 2021, 5:33am UTC](https://discuss.aerospike.com/t/write-generation-policy-multi-threaded-application/8339 "2021-03-26T05:33:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gtgoudar](https://avatars.discourse-cdn.com/v4/letter/g/4da419/32.png) [@gtgoudar](https://discuss.aerospike.com/u/gtgoudar)\
**Post date:** [March 26, 2021, 5:33am UTC](https://discuss.aerospike.com/t/write-generation-policy-multi-threaded-application/8339/1 "2021-03-26T05:33:08Z")

</div>

All,

In a multi threaded application, where writes have to be done in parallel, how can you implement “GEN\_EQUAL” policy? We cannot use the same WritePolicy object because any other thread can update the “generation” value before the “put” happens for that record.

Another option would be to create a “WritePolicy” object for each record, but this will end up with “n” number of WritePolicy objects for n records.

Any help is appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![neelp](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/neelp/32/1369_2.png) [@neelp](https://discuss.aerospike.com/u/neelp)\
**Post date:** [March 26, 2021, 9:50pm UTC](https://discuss.aerospike.com/t/write-generation-policy-multi-threaded-application/8339/2 "2021-03-26T21:50:45Z")

</div>

In Python, the generation value to check against is specified separately in the meta argument. See [here](https://github.com/aerospike/aerospike-dev-notebooks.docker/blob/main/notebooks/python/transactions_rmw_pattern.ipynb). In Java, it is part of the WritePolicy object. A write-specific WritePolicy can be constructed from a global WritePolicy object and the correct write-specific generation assigned to it. As you point out, in this case, you will need as many WritePolicy objects as concurrent writes. This should not pose any problem. Please let us know if you think there would be or experience any issues.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/system/32/2274_2.png) [@system](https://discuss.aerospike.com/u/system)\
**Post date:** [March 26, 2022, 9:51pm UTC](https://discuss.aerospike.com/t/write-generation-policy-multi-threaded-application/8339/3 "2022-03-26T21:51:01Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
