Sunteți pe pagina 1din 6

Conclusion

During making of the project we came across many Pros and Cons that we’ll be
discussing in this section of our report. Also, we’ll suggest some possible
improvements that can be further implemented. At the end we’ll put up some
Review Questions that would help in proper analysis of the Project.

Major points that needs to be concluded at the end of our project making process:

 We analyzed how multitasking has become synonymous with efficiency


towards the critical shortage of time where an efficient program is the one
that lets you execute multiple tasks using the same program. Such an
efficient program could be created using the Java programming language.

 Implementing multithreaded Java code is reasonably straightforward. The


results are actually quite impressive.
 Our GUI is freed up from long waits and ready to process other user actions.
However, the application might or might not permit the interleaving of
operations
 For application operations where it's okay to interleave user actions, making
a GUI multithreaded can be very useful. It can even help to improve end
user productivity by allowing a number of application operations to proceed
in parallel.
Advantages:

Following are some of the common advantages of multithreading:

 Enhanced performance by decreased development time


 Simplified and streamlined program coding
 Improvised GUI responsiveness
 Simultaneous and parallelized occurrence of tasks
 Better use of cache storage by utilization of resources
 Decreased cost of maintenance
 Better use of CPU resource

Disadvantages:

Multithreading does not only provide you with benefits, it has its disadvantages
too. Here we some common disadvantages:

 Complex debugging and testing processes


 Overhead switching of context
 Increased potential for deadlock occurrence
 Increased difficulty level in writing a program
 Unpredictable results

Further Improvements to the Problems:

1) Difficulty in writing Code:


When we checked the guideline to use threads, it seemed simple: it just extends
and implements some functions. But it’s not really as simple as it appears, as we
had to take care for a lot of things afterwards.
When you apply multithreading, you will push a lot of threads together at same
time, on the same data, same objects, and same functions. If you don’t have a good
way to control them, everything will become terrible. So that’s reason why we
need expert person-to-design multithreading.

 Solution to the problem:

 Replace Any Function or Code That Are Not Thread-Safe:


Our source code can be called thread-safe if all threads go inside the
same function at the same time, and each thread can get exactly the data
which they expected not the data of other thread.

There are many cases which make your source code not thread-safe,
including static variables, static function, and singleton class, to name a few.
If all threads run same time, they will use the same static variables or
function, and this thread will get the data of another thread.
Three ways to make an object thread-safe are:

 Synchronizing the critical sections. When you do that, only 1 thread


can work with this part at 1 time, but take care when you use that, only
for the source code which all thread can’t run together. This one will
make the performance go down.
 Use immutable objects. Immutable objects are simply objects whose
state (the object’s data) can’t change after construction.
 Use thread-safe wrappers. This means you put the main class (which
isn’t thread-safe) inside a new class that is thread-safe. This way is
helpful when the main class from third party or can’t update.
 Ignore Deadlock

The deadlock happens when one thread is waiting for the resource of
other thread, but the other thread still waiting for the resource which
keep by the first thread.
To ignore the deadlock, we have to ensure that:

 Each thread has to process different data.


 Each thread have to create own object and function by
themselves.
 Don’t share the data between threads.

 Careful When Using Synchronized


Inside multiple threads when we use this one, it will make the
performance go down, you have to make it as small as you can, only
use it when you have to use.
2) Difficulty in Testing and Debugging:
With simple thread you can easily test and debug, and see the work flow of data
inside your function, but if all threads run together, you can’t do it.

 Solution to the problem:


 Keep the number of threads as a input parameter of main
function if you can. And when something happens, we can set the
number of threads to 1, and we have a single thread to test and
debug.
However, this way just supports finding the business bugs, and the
bugs of single thread. If we got the problem with multiple threads
like each threads have conflict with each other, this way is not
helpful.
 Add useful log to the thread. The log is so powerful, try to put
the log at the position which you can see the running flow, and you
can see the whole flow. Write log when the exception happen, I
hate to catch java. lang.Exception but if you want the thread keep
going on the next data, you have to catch it, to make sure
everything is under control.
At the first time running we can put a lot of log info to your source
code, and when everything runs stably, you can remove them. But
don’t make it too big.
 Use the tool to test. When multiple threads are running, you can
use the tool to see how the threads running, which one is running,
which one is not, the status of each thread, and so on.

S-ar putea să vă placă și