programming:java:multithreading
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| programming:java:multithreading [2023/11/01 07:31] – removed - external edit (Unknown date) 127.0.0.1 | programming:java:multithreading [2023/11/01 07:31] (current) – ↷ Page moved from camunda:programming:java:multithreading to programming:java:multithreading skipidar | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Multithreading ===== | ||
| + | ^What ^Where ^ | ||
| + | |Introduction | [[http:// | ||
| + | |Whereever possible use the safe Structures from | [[http:// | ||
| + | |||
| + | |||
| + | === PitFalls === | ||
| + | - Do not use **TimeStamps** to synchronize Threads. Therere can be more than 1 action every millisecond - what to do with equal TimeStamps? | ||
| + | |||
| + | |||
| + | === Concurrent Package === | ||
| + | Das [[http:// | ||
| + | |||
| + | |||
| + | ^Class ^ What ^ | ||
| + | | [[http:// | ||
| + | | [[http:// | ||
| + | |||
| + | |||
| + | === ForkJoin === | ||
| + | A framework to execute parallel task. The mechanism is [[http:// | ||
| + | |||
| + | |||
| + | [[http:// | ||
| + | <sxh java> | ||
| + | //A nice way to stop the UI thread, in order to wait for a job, without blocking the UI Jobs coming from other Threads | ||
| + | while(job.getResult()==null) { | ||
| + | Display.getDefault().readAndDispatch(); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | === Try-Catch is Bypassed in nested threads === | ||
| + | On every thread there should be an own Exception-handling. Putting a new Thread creation into try-catch block won't catch the Exceptions. | ||
| + | |||
| + | <sxh java> | ||
| + | // | ||
| + | try{ | ||
| + | Runnable r = new Runnable() { | ||
| + | |||
| + | @Override | ||
| + | public void run() { | ||
| + | System.out.println(" | ||
| + | |||
| + | Display.getDefault().syncExec(new Runnable() { | ||
| + | @Override | ||
| + | public void run() { | ||
| + | System.out.println(" | ||
| + | throw new NullPointerException(); | ||
| + | } | ||
| + | }); | ||
| + | |||
| + | } | ||
| + | }; | ||
| + | |||
| + | Thread t = new Thread(r); | ||
| + | t.start(); | ||
| + | |||
| + | }catch(NullPointerException e){ | ||
| + | // | ||
| + | } | ||
| + | |||
| + | System.out.println(" | ||
| + | </ | ||
