Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6787205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:20:17+00:00 2026-05-26T17:20:17+00:00

I use play to develop my project and embedded netty3 as my application server

  • 0

I use play to develop my project and embedded netty3 as my application server
Please check the following test code:

package controllers;  
import java.io.File;  
import java.io.IOException;  
import java.util.HashMap;  
import java.util.Map;  
import java.util.concurrent.atomic.AtomicInteger;  

import org.apache.commons.io.FileUtils;  

import play.Logger;  
import play.Play;  
import play.mvc.Controller;  
import play.mvc.results.RenderText;  

public class Upload extends Controller {  

    private static Integer counter = 0;  
    private static final Integer MAX = 1;  

    public static void index() {  
        render("/upload.html");  
    }  

    public static void upload(File file) {  
        System.out.println("start " + Thread.currentThread());  
        synchronized (counter) {  
            System.out.println("middle " + Thread.currentThread());  
            if (counter > MAX) {  
                renderText("Sorry, the max upload thread is " + MAX);  
            } else {  
                counter++;  
                uploadFile(file);  
                counter--;  
                renderText("Upload success");  
            }  
        }  
        System.out.println("end " + Thread.currentThread());  
    }  

    static void uploadFile(File imgFile) {  
        File file = Play.getFile("/uploads");  
        try {  
            FileUtils.copyFileToDirectory(imgFile, file);  
        } catch (IOException e) {  
            Logger.error("upload file error", e);  
        }  
    }  

}  

When I opened two browsers(Firefox and Chrome) to upload the files at the same time, I debugged breakpoint in the ‘ upload(File file)’ method. But I found only 1 thread was processing.
After that, then the second request came.

The output is :

start Thread[play-thread-1,5,main]
middle Thread[play-thread-1,5,main]
start Thread[play-thread-1,5,main]
middle Thread[play-thread-1,5,main]

But in Tomcat/Jetty, there were two threads output in the console.

Did any body meet the same problem before ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:20:18+00:00Added an answer on May 26, 2026 at 5:20 pm

    I assume that you are running in Dev mode?

    The play document says that to make debugging easier, by default Play runs in a single thread model in Dev mode, and in production mode it runs as numbers_of_cores + 1.

    You can override this in the application.conf.

    # example of using a thread pool of 3
    play.pool=3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I develop an application using the Play! Framework which makes heavy use of the
I use media player control to play mp3 files in asp.net application. I want
I use the below mod rewrite code for urls like: www.site.com/play/543 RewriteEngine On RewriteRule
I'd like to use C# to implement an application that can play multiple audio
I found an old question How to use the Play framework to develop a
I´ve just started to test, use and play with facebook apps. I´ve searched stackoverflow
I an trying to develop a windows application using C# that can play streamed
Here is the code that I use to play around with. I want to
I'm getting the following NullPointerException while trying to use the Play FBConnect module: Caused
We deploy our webapp in tomcat6. it develop with play!framework. we want to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.