Can you give a very simple example of Java ThreadManager running in Google Apple Engine?

24 views
Skip to first unread message

Hung Ha

unread,
Jan 15, 2016, 11:30:24 AM1/15/16
to Google App Engine

Tried to run this code in App Engine but got Permission error

new java.util.Timer().schedule( 
            new java.util.TimerTask() {
                @Override
                public void run() {
                    // your code here
                    list.remove("coo");
                }
            }, 
            3000 
    );

The above code run periodically every 3 seconds.

I want to do the same in Google App Engine, but do not know how. I heard that we can useThreadManager or Runnable or something likes that.

So, can you give a very simple example of how to run a Thread inside Google Apple Engine?

Nick (Cloud Platform Support)

unread,
Jan 15, 2016, 4:42:00 PM1/15/16
to Google App Engine
Threads cannot be opened in the direct, traditional fashion in App Engine, due to runtime sandbox restrictions. You can use com.google.appengine.api.ThreadManager to spawn threads. Read the "Threads" section of the first linked doc to see more details. Be aware that they will need to join before the HTTP response is finally sent and the servlet method terminates.
Reply all
Reply to author
Forward
0 new messages