简体   繁体   中英

How to identify an Application as Single threaded or Multi threaded?

How can i know whether the Application i am developing is single threaded or multi threaded? For example is StackOverflow a multi threaded or single thread Application?

We all login into stackoverflow, does that mean... at the same time n users are trying to access stackoverflow login class... checkLogin Method?

So should we declare the checkLogin method synchronized ?

How can you possibly not know whether the application you are developing is multithreaded? You're the developer!

However in Java, unless you have completely managed to avoid using Thread.start(), Swing, AWT, RMI, garbage collection, a servlet container, etc etc etc, your application is multithreaded.

StackOverflow is not a common (desktop) application, it's a web application.

Web applications run on some sort of application server, which is almost always a multi-threaded program.

Regarding synchronized methods, you only need to add synchronization if multiple threads executing the method at the same time could cause unexpected behavior. That usually - but not always - happens when the method modifies shared variables (a counter variable, for instance) or accesses some limited resource (a socket for example).

您可以使用OllyDbg之类的调试器检查通用应用程序是否是多线程的

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM