Timer replacement for Appengine

0 views
Skip to first unread message

Zero Trick Pony via StackOverflow

unread,
Jul 7, 2014, 7:55:14 PM7/7/14
to google-appengin...@googlegroups.com

To answer your question as asked:

I just found out that appengine does not allow timers! Why??

java.util.Timer is implemented using a Thread, which AppEngine does not allow except using its own API. So when you try to use java.util.Timer, you get an exception:

java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
    at java.security.AccessController.checkPermission(AccessController.java:565)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at com.google.apphosting.runtime.security.CustomSecurityManager.checkPermission(CustomSecurityManager.java:56)
    at com.google.apphosting.runtime.security.CustomSecurityManager.checkAccess(CustomSecurityManager.java:131)
    at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
    at java.lang.Thread.init(Thread.java:378)
    at java.lang.Thread.<init>(Thread.java:432)
    at java.util.TimerThread.<init>(Timer.java:499)
    at java.util.Timer.<init>(Timer.java:101)
    at java.util.Timer.<init>(Timer.java:132)

Disallowing arbitrary thread creation makes it easier for the AppEngine system to manage multiple applications on the same machine without interfering with each other too much.

AppEngine is offering a new service called "Managed VMs" which will allow any environment you want, including a full JVM that can have background threads: https://developers.google.com/appengine/docs/managed-vms/

Note that this API is currently in "preview" which means it is not yet recommended for reliable production use.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/13421872/timer-replacement-for-appengine/24621725#24621725
Reply all
Reply to author
Forward
0 new messages