Allocates a slot of per-thread storage space and returns an index to it.
public static int allocThreadStorage()
Returns an index of the newly allocated thread storage slot.
Each thread in an application can allocate a slot of memory for storing data that is specific to the thread. Use this per-thread storage to define and store global variables for the thread or other information that is important to the thread. The index returned by allocThreadStorage is always greater than zero.
The following example demonstrates how to use the allocThreadStorage, setThreadStorage, freeThreadStorage, and getThreadStorage methods to allocate, store, retrieve, and free thread storage.
int storeIndex; public void createStorage() { //Create thread storage for the current thread storeIndex = Application.allocThreadStorage(); //Store a value in the thread storage Application.setThreadStorage(storeIndex, "A String Value"); } public void getStorage() { System.out.println("The value of the thread storage= " + Application.getThreadStorage(storeIndex)); Application.freeThreadStorage(storeIndex); }