Threading model: Linux, MacOSX, Win32

Hi,
I've been searching these forums for topics regarding Java threading models for the three operating systems for which we build Java applications: Linux, MacOSX and Windows. So far, I've only got a clear picture on the Win32 environment. It uses native threads, which I'm told is best for performance.
My question is: what threading models do the virtual machines for Linux and MacOSX support these days? Are they working with socalled "green threads" or do they use the more powerful native threads as well? I can't seem to find any recent posts with information on this subject.
Thanks in advance

Here is an article that you might find interesting:
Programming Java threads in the real world
http://www.javaworld.com/javaworld/jw-09-1998/jw-09-threads.html
Jesper

Similar Messages

  • Native pthread mutex on 1:1 threading model

    Hi,
    I wanted to verify with the experts that it is safe to use a native mutex in JNI instead of
    MonitorEnter/MonitorExit on all JREs that map a java thread to a native thread in a
    1:1 fashion. Why do this? Because MonitorEnter/Exit pair takes 500 nanos which
    is way to slow for my JNI component. Of course, on threading models that
    are not 1:1 I am definitely not safe(?).
    By the way, does anyone know if the SUN hotspot for windows is a 1:1 threading model.
    I know that it is for Linux.
    Andy

    i know that it's old but some other ppl can found it.
    actually i'm using a pthread_mutex_lock on linux/unix and WaitForSingleObject on windows. see, i don't create threads inside the jni glue, but i create mutexes.
    it seems to work well, but for some unknow reason it leads to deadlocks on certain unices.
    right now i'm going to change my implementations for MonitorEnter/Exit and GetPrimitiveArrayCritical.

  • ThreadGroup.activeCount()... Linux Vs Win32

    I've an app which uses ThreadGroup.activeCount() to controll the number of threads being created. Each thread will do:
    1) call some native OS commands like cp (Linux) or xcopy (Win32)
    2) some other SQL updates
    When I run my app on Windows 2000, the ThreadGroup.activeCount() is always equal to the number of threads (an object implementing Runnable) being created; however on Linux, it doesn't. It looks like every runnable object uses more than 1 thread on Linux (I print out the activeCount() whenever the runnable object is being instantiated).
    Is it because using Process.exec() to perform "cp -r" inside a thread will count as a sub-process to its parent on Linux/UNIX environment?
    Thanks in advance!

    He quoth not what he actually knows. No, the difference in threads in the two systems (Windows and Linux) is how the OS reports thread usage to itself and the memory and control processes. It's very easy to see a runaway thread in Linux, whereas all a Windows user knows is that his app is hung up. Debuggers in Linux have a much easier time getting the data about the various threads than they do on Windows.
    This comparison is only valid for the NT-series Windows - they're the only ones that have a real multi-tasking kernel. Not being a user myself, I seem to remember hearing that they're still based on a 20-year old POSIX kernel. Might be FUD, but I really don't care... ;D

  • Java 5 threads in linux

    Hi,
    I am using the following java version in Linux
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
    Threads are created using the source code:
    private static ExecutorService thPool = Executors.newFixedThreadPool(5);
    My question is how threads are created in linux using the mentioned runtime.
    1. Does the code line above create 5 linux native threads (process)?
    2. Does it create java threads? Don't know if java and native threads are same.
    3. If answer of the question 1 is "NO" then does one native linux threads for java runtime do all the concurrent execution?
    Please explain. Any documents on java threads in Linux for java 5?
    Thanks in advance
    Sunny

    What is your problem that makes you worry aboutthose things?
    Java for Linux uses NPTL thread library for itsthread.
    Browse the link to see what I wanted:
    http://groups.google.com/group/comp.lang.java.programm
    er/browse_thread/thread/2848feac5cd52151/9b6f6bf226ca9
    ef0?lnk=raot#9b6f6bf226ca9ef0reply 1, again. I don't understand your problem yet.

  • Alternative Threading Model in Solaris 8?

    I haven't been able to get to any Solaris 8 docs yet, but I've been hearing about his alternative threading model available in Solaris 8. Can someone explain it to me?

    I know this question was posted a while ago, but this info may be of help.
    As well as improved real-time support for threads, Solaris 8 has an extra set of thread libraries under /usr/lib/lwp.
    They are designed to be direct replacements for the standard libraries; you can pick them up by linking against them or using LD_LIBRARY_PATH.
    This new one-level libthread is a library that implements all of the POSIX and Solaris threads interfaces using a one-level threading model, where threads are one-to-one with lightweight processes (LWPs), rather than the two-level model that is used in the standard libthread implementation, where user-level threads are multiplexed over possibly fewer LWPs.
    It has been found in tests that some applications perform much better with the new library. However, more kernel resources are consumed.
    Hope that helps.
    Ralph
    SUN DTS

  • Xsql servlet threading model?

    does anybody know the threading model supporting by the xsql servlet? from my testing, it appears that it only supports single threaded.
    environment: nt 4.0, svcpack 5/iis/servlet exec 2.2/jdk 1.1.8/xsql servlet 0.9.6
    any help/info appreciated.
    thanks
    michael lasmanis

    steve,
    here are the java vm settings from servlet exec. all the other settings are in line with the install instructions.
    VM Settings
    Java VM: 1.1.8 from Sun Microsystems Inc.
    JITC: symcjit
    Host: Windows NT 4.0 on x86
    Native Stack Size: 128K Bytes
    Java Stack Size: 400K Bytes
    Minimum Heap Size: 1024K Bytes
    Maximum Heap Size: 524288K Bytes
    Verbose GC: Disabled
    Verbose: Disabled
    JITC: Enabled
    Class GC: Enabled
    Async GC: Enabled
    Verify: Remote
    Java VM: Sun Classic
    null

  • Single Threaded Model JSP- Servlet

    Servelts can be set to have thread safe access (Single thread model). However, when a JSP is converted in to a servlet, is the servlet tagged as to use the single thread model?

    As of JSP specification 1.2 the default value for the "isThreadSafe" attribute of the page directive is true indicating that the container can direct multiple requests to the page simultaneously. If this value is set to false then the requests will be sent one at a time.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • JColorChooser hangs event thread on Linux x64

    I am finding that repeatedly displaying a JColorChooser, picking a color, and clicking "OK" will hang the event thread in 64-bit Ubuntu 9.04 (Java 6 Update 13). Usually it takes between 2 to 20 launches of the JColorChooser before the color chooser will not launch and the UI is frozen. I cannot reproduce this using 32-bit Windows XP. I can even use the Sun Java Tutorial code and the problem occurs every time (Tutorial Link for a Color Editor in a JTable: http://java.sun.com/docs/books/tutorial/uiswing/examples/components/TableDialogEditDemoProject/src/components/ColorEditor.java).
    Has anyone else seen this problem and found a workaround of any kind? Or has anyone tested this on 64-bit linux with Java 6 without problems? Thanks much to all for any help.

    Here is a testbed that will produce the problem for me.
    * 1) Run the testbed.
    * 2) Click the button.
    * 3) Pick a new color swatch.
    * 4) Click OK.
    * 5) Repeat steps 2-4 until the color chooser does not launch.
    * (This was between 1 and 25 times for me)
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JColorChooser;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    * This class demonstrates a problem with JColorChooser.
    * I encountered this problem launching a color chooser from a
    * table cell, thus this example is based on table cell editor
    * code from the Java Tutorial (ColorEditor.java). I have added a
    * main() and removed some of the Table related noise.
    * 1) Run.
    * 2) Click the button.
    * 3) Pick a new color swatch.
    * 4) Click OK.
    * 5) Repeat steps 2-4 until the color chooser does not launch.
    * (This was between 1 and 25 times for me)
    public final class ColorChooserTest implements ActionListener
    private Color currentColor = Color.BLUE;
    private final JButton button = new JButton("Push Me");
    private final JColorChooser colorChooser;
    private final JDialog dialog;
    private static final String EDIT = "edit";
    private final JFrame frame = new JFrame("JColorChooser TestBed");
    public ColorChooserTest() {
    button.setActionCommand(EDIT);
    button.addActionListener(this);
    button.setBorderPainted(false);
    button.setBackground(currentColor);
    //Set up the dialog that the button brings up.
    colorChooser = new JColorChooser();
    dialog = JColorChooser.createDialog(button,
    "Pick a Color",
    true, //modal
    colorChooser,
    this, //OK button handler
    null); //no CANCEL button handler
    final JPanel holder = new JPanel(new BorderLayout());
    holder.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
    holder.add(button, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(holder, BorderLayout.CENTER);
    frame.pack();
    public void actionPerformed(final ActionEvent e)
    if (EDIT.equals(e.getActionCommand()))
    //The user has clicked the cell, so
    //bring up the dialog.
    button.setBackground(currentColor);
    colorChooser.setColor(currentColor);
    dialog.setVisible(true);
    else
    //User pressed dialog's "OK" button.
    currentColor = colorChooser.getColor();
    button.setBackground(currentColor);
    public static void main(final String[] args)
    final ColorChooserTest x = new ColorChooserTest();
    x.frame.setSize(300, 300);
    x.frame.setVisible(true);
    }

  • Need help interpreting jvm thread dump (linux)

    hi,
    i'm using jre1.4.2 and running AS3 Linux kernel version 2.4.
    i grep'ed for my java process id, and did a kill -3 on it to get the thread dump:
    ps -ef |grep Eatroot 3936 3845 68 16:12 pts/2 00:00:05 java EatCpu
    root 3948 30293 0 16:12 pts/3 00:00:00 grep Eat
    kill -3 3936
    thread dump:
    java EatCpuFull thread dump Java HotSpot(TM) Client VM (1.4.2_05-b04 mixed mode):
    "Thread-0" prio=1 tid=0x081126b8 nid=0xf60 runnable [aa7e0000..aa7e087c]
    at EatCpu.run(EatCpu.java:31)
    "Signal Dispatcher" daemon prio=1 tid=0x080a6a58 nid=0xf60 waiting on condition [0..0]
    "Finalizer" daemon prio=1 tid=0x08092ee8 nid=0xf60 in Object.wait() [aad4d000..aad4d87c]
    at java.lang.Object.wait(Native Method)
    - waiting on <0xaaed0490> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
    - locked <0xaaed0490> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    "Reference Handler" daemon prio=1 tid=0x08091498 nid=0xf60 in Object.wait() [aadce000..aadce87c]
    at java.lang.Object.wait(Native Method)
    - waiting on <0xaaed0380> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:429)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
    - locked <0xaaed0380> (a java.lang.ref.Reference$Lock)
    "main" prio=1 tid=0x0805bae0 nid=0xf60 runnable [bfffc000..bfffcc98]
    at EatCpu.main(EatCpu.java:22)
    "VM Thread" prio=1 tid=0x08090238 nid=0xf60 runnable
    "VM Periodic Task Thread" prio=1 tid=0x080a9248 nid=0xf60 waiting on condition
    "Suspend Checker Thread" prio=1 tid=0x080a6020 nid=0xf60 runnable
    i read that "nid" in the thread dump is suppose to correspond to PID. when i give the -m option for the "ps" command (for all threads), i see:
    ps -efm |grep Eatroot 3936 3845 43 16:12 pts/2 00:00:04 java EatCpu
    root 3937 3936 0 16:12 pts/2 00:00:00 java EatCpu
    root 3938 3936 0 16:12 pts/2 00:00:00 java EatCpu
    root 3939 3936 0 16:12 pts/2 00:00:00 java EatCpu
    root 3940 3936 0 16:12 pts/2 00:00:00 java EatCpu
    root 3941 3936 0 16:12 pts/2 00:00:00 java EatCpu
    root 3942 3936 0 16:12 pts/2 00:00:00 java EatCpu
    root 3943 3936 0 16:12 pts/2 00:00:00 java EatCpu
    root 3944 3936 30 16:12 pts/2 00:00:03 java EatCpu
    root 3950 30293 0 16:12 pts/3 00:00:00 grep Eat
    >
    but nid for all threads in the thead dump is the PID of my main process, 3936 (0xf60). is there a way to correlate the PIDs produced by "ps -efm" to the threads in the thread dump?
    thanks!
    -annie

    i upgraded to 1.5 version of java, and could see distinct "nids" in the thread dump after that..

  • Reduce number of running thread under Linux

    Hello,
    How can reduce the number of running thread for coldfusion MX
    7.0.2 server under Linux (they are almost 30; )

    If you create a pool of any sort you will need a point where all requests for a resource from the pool must go via, and that piece of code could potentially become a bottle neck. But if you develop it well there will be a very small piece of code that is sychrnonized that will either put a request in a queue as there are no resources available, or it will provide the requested resource. As far as i am aware there is no safe way around this as you will have multiple threads requesting the resource.

  • Maximum simultaneous opened files in a java thread on linux 1.4.20

    Hello,
    It seems like a maximum of 1024 files can be opened by a processus on linux (in java, a thread is a linux processus).
    Is it possible to change this value, or has it been set at the JVM compilation?
    I created a nio server, and one thread is to manage thousands of connections. For the moment I can't pass 1010 connections.
    As a fast test, I created the following source :
    public class MaxOpenedFilesTest {
    /** Creates a new instance of MaxOpenedFilesTest */
    public MaxOpenedFilesTest() {
    * @param args the command line arguments
    public static void main(String[] args) {
    File f = new File("/home/greg/a.out");
    FileInputStream[] stream = new FileInputStream[2000];
    try {
    for (int i=0; i<stream.length; i++) {
    stream[i] = new FileInputStream(f);
    System.out.println(i+" files opened");
    catch (Exception e) {
    System.out.println("ERROR : "+e);
    e.printStackTrace();
    This test throws an IOException at 1019 files opened : Too many opened files...
    I have tested a lot of things. I even recompiled the linux kernel. Changed the NR_OPEN, OPEN_MAX, __FD_SETSIZE, etc... Still don't work.
    I havve set the global maximum file descriptor to 65536. It works. But for one thread, I can't have more than 1019 file descriptors (must be the 1024 initial limit defined by the kernel)...
    Could somebody help.
    It would be great.
    Thank you.
    Gr�goire.

    Thank you for your answer.
    I have already done all the described procedures in the link you provided.
    In fact, I used this link :
    file:///home/greg/1_NetNoLedge/LinuxTuning/linux.html
    and this other one :
    file:///home/greg/1_NetNoLedge/LinuxTuning/s1-custom-kernel-modularized.html
    Still only 1024 files allowed to be opened for one process...
    In your link, it is said :
    You need to give processes the option of increasing their file descriptor limits:
    In /etc/security/limits.conf add two lines:
    * soft nofile 1024
    * hard nofile 4096
    Suggesting that it wouldn't even be necessary recompile the kernel to allow more opened file descriptors in a process... This really isn't clear for me.
    Thank you.

  • Struts Action threading model bottleneck

    Hi,
    Struts Action classes are only instantiated once. Then the controller servlet routes all perform/execute calls through the single instantiated Action class. Does this create a performance bottleneck? Any insights would be helpful.
    Thanks

    It's more performant, since it doesn't need to create new objects for each request. You just need to write your code in a thread-safe manner (watch the instance variable!).
    Cheers

  • BPEL Threading Model

    I have three BPEL Processes: BPEL1, BPEL2 and BPEL3 invoking each other in a synchronous fashion as shown below:
    Synchronous flow - BPEL1 -> BPEL2 -> BPEL3
    I have a java web service which sends in the request to the BPEL1. I would like to increase the no of threads to handle more requests from the Java web service. I looked up four parameters that can be tuned:
    Dispatcher Invoke Threads
    Dispatcher Engine Threads
    Dispatcher System Threads
    Dispatcher Maximum Request Depth
    As per my understanding Dispatcher Invoke Threads comes into the picture when a synchronous transaction is involved. The question I have is:
    Is the value of 20 per instance of BPEL Process or per synchronous transaction? With the above flow stated, BPEL1 invoking BPEL2, BPEL2 invoking BPEL3 and response flow from BPEL3 to BPEL2 and BPEL2 to BPEL1, all being synchronous calls, is this parameter for every instance of BPEL1 alone (per synchronous transaction) or per BPEL instance of BPEL1,BPEL2 and BPEL3?*

    No, "Dispatcher Invoke Threads" come into play with async (oneway / possible callbacks). This setting controls the threadpool size to create new process instances, after the originator thread saved the instance data and returned.
    Engine threads handle callbacks and expirations
    System threads are cleanup threads

  • Cannot reinstall from CD-ROM on Linux/MacOSX laptop

    I've inherited this old 17" Powerbook G4 from where I work. The previous owner was a sysadmin who has some kind of dual install on the laptop. So, when you turn the power on it gives you a choice to boot up in Linux or OSX. I want to completely start-over from scratch on this machine. I have the CD-ROMs that came with the laptop, but I'm having problems.
    1) I can put the CD-ROM in and get an additional option when I turn the power on to boot from the CD-ROM. This results in the fatal crash screen, but it's overlayed with a bunch of Linux code.
    2) I can boot in OSX and then choose to reinstall from the CD-ROM menu. The laptop powers down and restarts, but the results are the same as in #1.
    What are my options? Can I physically remove the hard drive from the laptop, reformat it using my personal laptop, put the hard drive back in the laptop and then launch from the CD-ROM?

    Thanks for the reply, eww.
    The disks I tried to reinstall with ARE NOT for the laptop in question. It didn't occur to me that that would be required. I just figured as long as it was a version of OSX that the hardware could handle, that it would work. Now that I think about it, it makes sense that you'd need the correct disks.
    Now my problem is the fact that I have about a 5% chance of locating those disks. The guys in my office aren't as disciplined as I am when it comes to keeping in mind where these things are.
    Is there a web site maybe that keeps disk images alive? Are there any alternatives to using the original disks that came with the laptop?

  • Multi-threaded program hangs in Linux with green thread when doing I/O

    Hi,
    I am using green thread(jdk1.3.1) on Linux. My program is in multi-threaded model and has some I/O operations. I am runing one java program using Runtime.exec("java <program>"). Actually the <program> prompts user with some question like "enter location" and waits for the input. Now in my code I am constantly reading the input stream of the process. Once I get the string like "enter location", immediately I send the location through Process o/p stream. But the process is not able to read this and hangs there for ever.
    Please help, what could be the problem? If you need the source code, pls let me know.
    Thanks in advance,
    Sisir

    I had a similar issue few weeks back... If I could see the source I would have a better understanding of the problem and think I could help out. If you want to send it, send it to [email protected]
    thanks,
    JP

Maybe you are looking for

  • White text on Black for SAPSCRIPT

    Hi Everybody I want to print some text as 'white on black'. Can you please tell me how to do that? Its from Sapscript. Rgds Chinmoy

  • Cover Flow view in iTunes 7

    I really like the cover flow view but it seems the albums are keyed on Artist so if different tracks have different artists, they show up as multiple albums in the cover flow view. Is there any way to make it key on Album name instead? iMac 20" Core

  • How different fields linked with Application Utilities Lookups

    Hi, I need to know how different fields at different forms are linked with utilities lookups and pick the values(meaning)? For example #1; at Organization form, Type of organization is must to define, value of Type comes from Utilities lookups. Type

  • Error installing Tuxedo 10gR3 for Linux  on CentOS 5.3

    Hi Colleagues, I am having probem installing tuxedo10gR3_64_Linux_01_x86.bin as part of PeopleSoft v9.1 install on my test server, CentOS 5.3 Linux. I am getting the error below. CentOSLinux:psoft /Tuxedo_10gR3_Linux >ls -l total 83464 -r-xr-xr-x 1 r

  • N8 Huge Camera Problem Found, Please Advice!!

    Hello all Nokia guys, I am a new member in this forum as well as to Nokia. I bought Nokia N8 on Sunday 5 th Dec 2010 ( Mumbai, India ). That day i did not test camerra in the night time. I clicked many photos during Day time and it looked just Gr8. N