This commit is contained in:
Ilkka Seppälä
2019-12-13 21:09:28 +02:00
parent 0335c61512
commit b2b1ba95eb
127 changed files with 282 additions and 450 deletions

View File

@ -5,10 +5,7 @@ folder: trampoline
permalink: /patterns/trampoline/
categories: Behavioral
tags:
- Java
- Difficulty-Intermediate
- Performance
- Recursion
---
## Intent
@ -31,14 +28,17 @@ Use the Trampoline pattern when
* For interleaving the execution of two or more functions on the same thread.
## Known uses(real world examples)
* Trampoline refers to using reflection to avoid using inner classes, for example in event listeners.
The time overhead of a reflection call is traded for the space overhead of an inner class.
Trampolines in Java usually involve the creation of a GenericListener to pass events to an outer class.
## Tutorials
* [Trampolining: a practical guide for awesome Java Developers](https://medium.com/@johnmcclean/trampolining-a-practical-guide-for-awesome-java-developers-4b657d9c3076)
* [Trampoline in java ](http://mindprod.com/jgloss/trampoline.html)
## Credits
* [library 'cyclops-react' uses the pattern](https://github.com/aol/cyclops-react)