Even if you execute the function once per nanosecond, it’ll take around 292 years(refer here) for the long data type to be fully used up. Since Long.MAX_VALUE is 9,223,372,036,854,775,807. If the overflow happens, you can wrap it to Long.MIN_VALUE
If you want to learn more about Java, then go through this Java tutorial by Intellipaat for more insights.