Suggestions for the FAQ

Please post suggestions for the FAQ here.
[48 byte] By [davidholmes] at [2007-11-26 12:06:47]
# 1

David,

I am interested in sources explaining concurrency. Especially in a (network) I/O situation. At this moment I can not define what I need. Therefore some (Internet) literature would be helpful. A short explanation of the different available systems to synchronize with, and in what situations these may be used could be helpfull too.

Maik

Maik at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 2
> Please post suggestions for the FAQ here. One I see floating about quite a bit is the difference between the use of volatile and synchronized blocks - and the guarantees or otherwise offered by both.
aconst_null at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 3
I do often see questions on what the difference is between synchronized method and synchronized block.Another question that is frequently asked is why you call wait/notify on an object instead of on the thread. Kaj
kajbj at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 4
Interesting feature that this forum has, and I didn't know. Cool, david!Now, about questions to the FAQ, one of them could be "How to stop a thread? What are the techniques for that?"
TheLooser at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 5
This feature has just been enabled at my request. :)Thanks for the initial suggestions (some easy, some not so). I will try to address them, but I don't want to rewrite "Java Concurrency in Practice" in the form of a FAQ. :)Cheers,David Holmes
davidholmes at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 6
FAQ updated December 19
davidholmes at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 7
> "How to stop a thread? What are the techniques for> that?"David,the response to this question is available here http://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.htmlMichele
michele81 at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 8

If Thread.currentThread() is called from within a Runnable, is the returned Thread the same Thread contains the Runnable or is it the Thread that declared the Runnable?

Maybe some code will help clarify. Given the following code:Final ArrayList<Thread> someThreads = new ArrayList<ArrayList>();

someThreads.add(Thread.currentThread());

Thread someStartedThread = new Thread(

new Runnable() {

public void run() {

someThreads.add(Thread.currentThread());

}

}

);

someStartedThread.start();

someStratedThread.join();

someThreads.add(someStartedThread);

Which two Threads in the someThreads ArrayList are the same: the first two or the second two?

The above example code could also be used to explain order guarantees, like what someThreads would contain if the someStartedThread.join(); line was removed.

You know... after thinking about it I think i know the answer: the last two are the same, because if that Runnable was declared in its own file then that would be the only Thread available to Thread.currentThread() from that context.

Message was edited by:

MutantPlatypus

MutantPlatypus at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 9
What do you get if you call Thread.someThread() some a static context, or from a static initializer?
MutantPlatypus at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 10
I guess what I should have said in the first place is I'd like to see questions in the FAQ that answer unusual questions, ones that aren't answered elsewhere.
MutantPlatypus at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...
# 11

> I guess what I should have said in the first place is

> I'd like to see questions in the FAQ that answer

> unusual questions, ones that aren't answered

> elsewhere.

:) By definition such questions are not "frequently asked" and so don't belong in the FAQ.

Unusual questions should be asked in the normal forum.

And as I say in the FAQ it isn't meant to be a tutorial. Some questions arise from a basic lack of knowledge of Java and/or threading.

davidholmes at 2007-7-7 13:10:20 > top of Java-index,Core,Core APIs...