File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multithreading on Linux

 
Drew Lane
Ranch Hand
Posts: 296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand that Solaris uses preemptive tasking for multithreading, and that Windows uses timeslicing, but what does Linux use (with respect to Java, of course)?
Thanks!
Drew
[ November 13, 2002: Message edited by: Drew Lane ]
 
Marcos R Oliveira
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Drew!
I am not sure what type of tasking Linux uses, but below is a code that can help you to find out.
If you run the application and the messages "Foo" and "Bar" alternate then Linux uses timeslicing. If "Bar" is never printed then Linux uses preemptive multitasking.

Hope this can help you,
Marcos.
 
Ron Newman
Ranch Hand
Posts: 1056
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would preemptive multitasking prevent the "Bar" thread from running? When "Foo" notifies and waits, that should be enough to wake "Bar" up.
 
Marcos R Oliveira
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh! I�m sorry!
In the code above I put a wait() call and the method imprime() to make a test. The code below is what I wanted to show here.

With this example, in a preemptive multitasking, "Bar" will never have the chance to be printed, while in a timeslincing "Foo" and "Bar" can be seen.
Thanks, Ron,
Marcos.
 
Ron Newman
Ranch Hand
Posts: 1056
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On MacOS X 10.2.2, which is based on BSD Unix, you see both "Foo" and "Bar'", but they do not alternate one for one. Instead, I get long stretches of Foo, followed by long stretches of Bar, then back to Foo, etc.
 
Jose Botella
Ranch Hand
Posts: 2120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It happens the same in Mandrake 9.0
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On Suse 8.1 it gives a couple of hundred Foos then sticks a few seconds, and then goes into a Foo-Bar flip-flop.
-Barry
[ November 15, 2002: Message edited by: Barry Gaunt ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic