08 June 2004 - java_dev (original) (raw)
Can someone explain a little to me about threads? I understand what they are, conceptually, and have used them by cut & paste (I don't really know what I'm doing..) .. but what I was wondering is, are there any "hard and fast" rules about when / where to use multiple threads to get things done?
All the excercises in my "big book-o-java" say "spawn one thread to do this, another to do this, do this, do that, etc" .. but when I'm working on my own projects, how do I know when it's a good idea?
And another question; what are the tradeoffs? I know multithreaded progs are better design-wise, but will multiple threads slow my apps down? chew more memory? when writing j2me for devices with 200k of heap, such things become very important..
Synchronization throws me a little, too.. but that's in the book. Any (non-null) pointers would be appreciated tho. :)
thanx.