out.println("<body>");
out.println("<h1>Getting ManagedThreadFactory using JNDI lookup</h1>");
try {
InitialContext ctx = new InitialContext();
ManagedThreadFactory factory = (ManagedThreadFactory) ctx.lookup("java:comp/DefaultManagedThreadFactory");
// ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("concurrent/myExecutor");
out.println("Getting ManageableThread<br>");
Thread thread = factory.newThread(new MyTask(2));
out.println("Starting thread<br>");
thread.start();
out.println("Thread started<br><br>");
} catch (NamingException ex) {
Logger.getLogger(TestResourceServlet.class.getName()).log(Level.SEVERE, null, ex);