Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As already pointed out, creating threads is a bad idea. In particular, once your application comes to a point at which very many lifepacks exist. Also note that starting a thread in a constructor is very bad practice. If you want to use plain threads, implementing a runnable (java.lang.Runnable) is advisable.</p> <p>In general, however, I would strongly encourage you to use the Java concurrency abstractions available in the java.util.concurrent package: <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/package-summary.html" rel="nofollow">http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/package-summary.html</a> Using an ExecutorService to run callables (java.util.concurrent.Callable) allows you to vary the number of threads quite easily.</p> <p>I would also question your idea of storing all the lifepacks in the same collection and assigning each of them a state (visiblity). Spontaneously, I could think of the following scenario: once the game runs for quite some time, you will end up with a large collection of lifepacks, most of which are not used anymore. Therefore, you might want to think about having different collections for the different states a lifepack can be in. This would also make throwing away object quite easy (without traversing a collection). Aussuming that those collections would be accessed by more than one thread, you'd want them to be thread-safe. For that, you'll find various types of collections in the java.util.concurrent package as well.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload