Login:  Password:    
forgot my password
sign up!
Search: 
 
  This post is part of:
    Online course(s):   
 Sun Certified Java Programmer 310-065

Threads - Concepts - Sun Certified Java Programmer 310-065 - Lesson 40 | Java courses

In this video, will see how we can implement the Runnable interface, and the use of the sleep() method.

"
download the application please visit www.mrbool.com/player

Title: Threads - Concepts - Sun Certified Java Programmer 310-065 - Lesson 40

Duration:  16 minutes

Summary: In this video, we start our discussion of Threads. Thread is a single unit of execution. Threads can be created by extending the Thread class and overriding the run() method. Thread objects can also be created by calling the Thread constructor that takes a Runnable argument. The first questions we tackle help us understand the signature of the methods available, how we can implement the Runnable interface, and the use of the sleep() method. This method has to exist in a try/catch block. Finally, we see how we can synchronize threads. By making the methods as synchronized, the threads will get the lock of the 'this' object before proceeding.

Methodology of the development of example: Good coding standard and simplified design to prepare for the Java programmer certification exam CX-310-065.

Technology Used: Java - Core Concepts.

Keywords: class, object, Thread, start(), run(), Runnable, sleep(), join(), wait(), notify(), notifyAll().





Add a comment!
[Fechar]

Este post é fechado - você precisa ter acesso ao post para incluir um comentário.


Matthew Casperson
4/19/2012 5:53pm
Watch for synchronize on a primitive
This web pages has some good tips on Java Concurrency:
http://tech.puredanger.com/2009/01/28/java-concurrency-bugs-synchronize-object/

In the video for question 4 we are told that the synchronized method as it is presented in option C is incorrect. This is true, but is not explained very well. The issue here is that the synchronized block can not lock on a primitive value, such as an int. Technically, with the way the question is worded, the two private variables held by the class could be Integer objects, like in the class below.

public class Test
{
private Integer a;
private Integer b;
public int read(){synchronized(a){return a+b;}}
public void set(int a, int b){synchronized(a){this.a=a; this.b=b;}}
}

In this configuration, the read() method will work. However, in the set() method, because the synchronized block is locking on "a" as opposed to "this.a", it has to be referring to the int parameter passed in by the method, which means the code is incorrect.


Answer it
 
Mr.Bool Editor
4/19/2012 7:34pm
RE:   Matthew,
send your review to the author of the video, soon, will contact


Answer it
 
Ayad
4/20/2012 1:25am
RE:   Hi Matthew,
 
Great feedback!
Unfortunately, as I mentioned in the other comment, I did not author the questions. If you notice in the videos I always give credits to the authors and making sure that readers know I did not author these questions.
The idea is that with some background, discussion, and feedback (like we are doing now :) ), readers will grasp the ideas and understand them better.
Keep up the good work.
 
Ayad


Answer it
 



 
Help us to improve! Give us your feedback:
Give your note to the technical content
10 9 8 7 6 5 4 3 2 1
Give your note to the post's learning
10 9 8 7 6 5 4 3 2 1
Is this post helpful?
Yes No


Ayad Boudiab
Experience: A total of 10 years experience in developing applications using C++, Java, C#, ASP.NET, and SQL Server. In addition to 6 years experience in teaching programming courses at a local college. Degree: B.S. Computer Science Location: Atla...


Go to author's Space


Post stats:
Favorited:
 1

Post actions:
[Close]
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 2,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 1,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,33
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!


> More info about MrBool Credits








mrbool.com
contact us   |   publish your post   |   buy credits

Copyright 2012 - all rights reserved to www.web-03.net