Showing posts with label threading. Show all posts
Showing posts with label threading. Show all posts

Tuesday, 28 April 2009

The Recursive Mechanics of java.lang.ThreadGroup

A ThreadGroup is a set of threads. Containment - a ThreadGroup can contain other ThreadGroups (which will be like "subtrees" of the original ThreadGroup). Threads within a group can share properties e.g. setMaxPriority will set max priority in group (method is called recursively, for every ThreadGroup in the ThreadGroup). A thread may only access information about its ThreadGroup.

ThreadGroup has a final checkAccess method to determine if the currently running Thread has permission to modify the ThreadGroup. If not, a SecurityException is thrown.

Wednesday, 4 March 2009

Dalla GreenThreads al NativeThreads

Does it make sense to talk about the Java threading model? Java, is of course, a naturally multi-threaded languages, but the threading model is mandated NOT by the spec but by the VM implementation, surely? In particular, what is the relationship between the Solaris threading model and the Java threading model?

threadingmodel( _Java, 1.1, GreenThreads). ? GreenThreads = simulatedThreadsInVm.
threadingmodel( _Java, 1.2, NativeThreads).

advantage( GreenThreads, _Linux, time(X), reason(Y)). ? X = earlyDaysOfJava, Y = saveCost(Z), Z=spawn(A, B), A=process, B=nativeThread.

threadingmodel( _solaris, X). ? X = manytomany, X = onetoone.
alias( manytomany, (_LWP|boundthread) ), alias( onetoone, _SolarisThreads ).
has_a( _LWP, kernelthread ). schedule(kernel, task(X)) :- on_a( X, _LWP ).
too_few(LWP) :- starvation(X), thread(X).


Sun's JVM also maps 1:1 to Windows threads (not multiple processes or fibers).