• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

Threadsafe BSFN Question

HighOnTek

Member
Not sure if this is still an issue, but I recall from my basic jde dev training that if you create or customize a BSFN and need to use/add variables that Global/Static variables should be avoided as they're not considered threadsafe, and could cause issues in environments that support multi-threading.

Is this right, have I properly recalled this information and does anyone have anything else they could add to this?
 

BOster

Legendary Poster
You recall correctly. Generally just avoid global or static variables and your good. If you call any third party libs you may need to keep thread safety in mind as well.
 
Hi,
When you are using the global variables in the business function.we must initialize that variable in the sub programs also at that movement you willn't face this problem...
 

BOster

Legendary Poster
Hi,
When you are using the global variables in the business function.we must initialize that variable in the sub programs also at that movement you willn't face this problem...
I hope I didn't mis-understand your post.

But to clarify - you really shouldn't be using global or static variables in business functions unless you have a REALLY, REALLY, REALLY valid reason to do so - such as interfacing with some third party lib/system. Even then I can think of better ways to store some type of static reference or handle to a third party lib/system aside from using a static or global variable. If you think you can declare a global/static variable and then simply "reinitialize" or set it every time a BSFN or subroutine is called then you don't understand thread safety.
 
Top