Quick Examples
This section presents seven examples of frequently-used scoped memory programming techniques.
newInstance can be used with constructors that have arguments, but the code that demonstrates that procedure is a bit long-winded. See Example 13-2.
Example 13-16. Allocating immortal memory
Object alsoImmortal; public void run(){ // Create an immortal object using the simple // form of newInstance try{ Object inImmortal = ImmortalMemory.instance(). newInstance(Object.class); } catch (IllegalAccessException access){ System.out.println(access); } catch (InstantiationException instant){ System.out.println(instant); } // Enter immortal, and use it to create an immortal // object ImmortalMemory.instance().enter(new Runnable() { public void ... |
Get Real-Time Java™ Platform Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.