Do threads created in Java behave differently on Windows and Linux?

前端 未结 3 1456
心在旅途
心在旅途 2021-01-17 09:13

As what I know, Java is using operating system threads (in contrast to i.e. Erlang), that means that the threads created with Java on Windows and Linux may behave different.

相关标签:
3条回答
  • 2021-01-17 09:40

    This is a very general question, so I'll give a general answer.

    Java switched from green threads, to native threads early in its development. This does not mean that threads created on Windows and Linux will behave differently as both platforms will utilize native threads in their respective JVM implementations.

    The thread interface exposed to Java by each OS, and similarly the native interfaces to threading via pthreads and Windows threads are very similar.

    The biggest differences with respect to threading on the two platforms are that all threads on Linux are a form of process. Windows treats threads and processes very differently.

    In my personal experience, native threads on Windows are slightly more lightweight and may perform slightly better within single process applications. Correspondingly (and perhaps irrelevant), are that Windows processes are extremely heavyweight compared with their Linux counterparts.

    0 讨论(0)
  • 2021-01-17 09:43

    I have already used thread in both OS, and no differences for the java developer. :)

    0 讨论(0)
  • 2021-01-17 09:52

    JVM hide all OS differences to you...

    as was previously answered the threads on windows are big heavyweight that linux ones.

    by experience a heavy multi threading application could have some delays with automatic memory garbage collector and those can generate huge memory peaks.

    0 讨论(0)
提交回复
热议问题