New improvement for Java syntax

Hi developers
I develop in java each day and the new project that I am envolved uses too much multithreading. So i thought that a litle improvement could be made on java syntax.
When two threads uses the same class attribute we must synchronize the access to this.
class myClass {
private int myAtribute = 0;
thread1: We must access the attribute synchronized....
shynchronized (this) {
myAttribute = 1;
thread2: The same....
synchronized (this) {
myAttribute = 3;
thread2: But if i don't care.... :-(
myAttribute = 4;
Ok, that is the problem.
I thought to solve this the java language must give us the chance to declare attributes in the way...
private synchronize int myAttribute = 0;
to be only accesed by sinchronized methods or by synchronized blocks in order to force interpreter to check if any method access this attribute without being synchronized in compiling time.

In your example, wouldn't the volatile keyword normally suffice?
private volatile int myAttribute = 0;Graeme

Similar Messages

  • New Features for Java GUI

    Hello everyone!
    Can anybody tell about new features in SAP GUI for Java. I think It's emasculate now. It doesn't contain New ABAP editor, Network graphic, normal Screen Painter... I really enjoy adding themes and other stuff, but when these functionality will be added?
    Thanks.

    Hi,
      I use Java GUI from version 6.40, so i didn't know new ABAP editor for years. Once somebody shows me its features ...and I found that it is really good editor compared with previous Notepad-like frontend editor. But I have to say that customized version od Gvim used as external editor is in 90% better then new ABAP editor (the only problem is that double click on object doesn't work, but some workarounds are known for double-click on locally defined objects).
    Graphical screen painter is generally good tool, but once I cannot find any feature (sorry, I forgot which one, it happens about 6 years ago). I ask a SAP guru sitting near me. He comes, switch graphical screen painter off and click to a box in non-graphical version of screen painter. Then he told me that some features are not accessible in graphical screen painter. It was last time I used graphical version of screen painter.
    Themes? Works .... at least for me (Linux 32 bit and now Linux 64 bit too).
    So I think that Java GUI is usable (at least on Linux/Mac, I am not sure how in works under Windows) but you cannot stick on all features (and maybe you can find better working variants of it). E. g. I have no problem with new ABAP editor, it would be much better for me, if I can open external editor clicking to "Change" button in SE38 directly instead of click plus selecting external editor from menu.
    Regards,
      Pavel

  • New tips for Java developers

    Hello to all Java developers!
    I’m new to the forum and I wanna say all of you hi. Wanna give you a link to one very interesting article on java development (Video Conversion System Implementation)
    http://techzone.enterra-inc.com/video/video-conversion-system-implementation/
    I want to discuss it with you here.

    In what way is that a tip for Java Developers? In what way is it related to Java Programming?

  • New user for java (Data type conversion)

    Hi all, I'm the newer from JAVA, just start to learn it few weeks before, there have some problem about me.
    I want to konw how to change the data type ??For example, if I have a string call year and store the char "1", how can I change that field to int type ?
    Thanks very much

    You should have a link to, or download, the API docs. You can see them on line at:
    http://java.sun.com/j2se/1.3/docs/api/index.html
    Look up the class Integer. It has a static method, parseInt() which takes a String argument and returns an int.. Since it is static, you can do the following:
    int value = Integer.parseInt(your_string);
    Then, to make it robust, you can put try/catch around it and catch NumberFormatException if you need to do error checking.

  • New Website for Java Game Downloads...

    Hi There,
    I hope this is the right place to post something like this, but I was on the forums back in December and needed advice on how to make executable .jar files, and now that I figured it out successfully, I wanted to share it with some fellow computer programmers in here.
    I have created four games programmed in the JAVA language, and they are all based on television game shows, including SUPER PASSWORD, BLOCKBUSTERS, SCRABBLE, and LINGO.
    They can be downloaded here:
    http://www.super-password.com/ctvgsd - Classic TV Game Show Downloads.
    All of the games, coding, sounds, pictures, and everything else was made by yours truly. If you're interested, take a look at it for yourself and see how the games are and if you think they are good!
    The website will also give you info on downloading the zip files and how to play each of the games!

    http://developers.sun.com/techtopics/gametech/reference/techart/index.html

  • New to OOP Java syntax

    Hello there, I'm new here and I'd be thankful if you help me a bit with my self introduction to Java. I'll write down a source of main and hope you will tell me my beginner's problems:
    import java.util.*;
    //public int createdInstances = 0;
    public class Students{
         private String name;
         private String course;
         public Enum Specialty{
              administrator, developer, designer, none
         public Specialty specialty;
         public Enum University{
              TU, SU, NBU, none
         public University university;
         private String email;
         private long phone;
         public static int instances;
         public Students(){
              this.name = "nullStudent";
              this.course = "nullCourse";
              specialty = Specialty.none;
              university = University.none;
              this.email = "none";
              this.phone = 0;
         public Students(String name, String course)     {
              this.name = name;
              this.course = course;
              specialty = Specialty.none;
              university = University.none;
              this.email = "none";
              this.phone = 0;
         public Students(String name, String course, String email, long phone){
              this.name = name;
              this.course = course;
              this.email = email;
              this.phone = phone;
         public void Viewer(){
              System.out.println("Name: " + name + " course: " + course + " @email: " + email + " #phone: " + phone);
    public class Tasks{
         public static void main(String args[]){
              Students guys = new Students();
              guys.Viewer();
    }Thanks in advance.

    You can make a method that converts a string to a Server like this:
        enum Server {
            CPU, RAM, HDD
        public Server stringToServer( String s ) {
            if ( s == "CPU" ) {
                return Server.CPU;
            } else if ( s == "RAM" ) {
                return Server.RAM;
            } else if ( s == "HDD" ) {
                return Server.HDD;
            } else {
                throw new IllegalArgumentException(); // or any other error handler :)
        }

  • I'm  a new bie for JAVA Development

    Hi All,
    I'm going to start JAVA development as my full time so far I was in support. I have worked with the basic level of JAVA as a support engineer. I have read Kathy, Sierra's Head First JAVA and the SCJP preliminary exams books. I wish to know for what books I can go on to read next. Seeking for friends's and experts suggestion before I move to buy.  Your suggestions and ideas are welcome.
    Thanks
    Mohammed@@

    Hi Mohammed,
    for starters it's Java (no acronym). Books are a very subjective thing. Have a look at the ratings and comments on different books on amazon, visit a local bookstore and flip through a couple of books. Nobody here knows what you'll need int future.
    Regards

  • New admin for java web server

    Hi,
    i just installed Sun Java System Web Server 7.0. besides intsalling it, i don't know how to use it.
    I am looking to add some files so users can view them. how do i go about doing that? I have no clue?
    I don't know how to use it just yet but can follow instructions rather well.
    i am a unix admin.
    thanks
    ~jv

    Ok.. it depends what type of content do you want to add.
    You can start by dropping html documents in your instance's document root directory, usually /sun/webserver7/https-configname/docs.
    making sure the server instance is running, hit the pages. And voila, you should be able to see it.

  • New in Kodo 3.3.3: Improved support for Java 5 enums and generics?

    Hello,
    Can anybody tell me if Kodo 3.3.3 can be deployed on WebLogic 8.1 sp4, jdk
    1.4.1? The reason I ask this is because one of the features mentioned for
    v3.3.3 is the support for Java 5 generics, which is available on WebLogic
    9 -- but not in WebLogic 8.1 sp4. The documentation for Kodo 3.3.3 seems
    to indicate that it can be deployed on WebLogic 8.1 -- can anyone tell me
    if this is accurate?
    Thanks for your help!

    Correction:
    I think that my question may have been misunderstood. What I want to know
    is if Kodo 3.3.3 can be deployed on WebLogic 8.1sp4 which is running JDK
    1.4 or do I have to deploy on a newer version of WebLogic that is running
    Java 5?
    Thanks!
    Rita wrote:
    I think that my question may have been misunderstood. What I want to know
    is if Kodo 3.3.3 can be deployed on WebLogic 8.1sp4 which is running JDK
    1.4 or do I have to deploy on a newer version of WebLogic that is running
    Java 4?
    Thanks!
    Stephen Kim wrote:
    Rita,
    While Kodo 3.3.x can work with JDK 5, it cannot make WL work with JDK 5.
    However, Kodo 3.4 RC 3 / 4.0 EA 2 both can work with WL 9 (which works
    with JDK 5).
    Rita wrote:
    Hello,
    Can anybody tell me if Kodo 3.3.3 can be deployed on WebLogic 8.1 sp4,
    jdk
    1.4.1? The reason I ask this is because one of the features mentionedfor
    v3.3.3 is the support for Java 5 generics, which is available on WebLogic
    9 -- but not in WebLogic 8.1 sp4. The documentation for Kodo 3.3.3 seems
    to indicate that it can be deployed on WebLogic 8.1 -- can anyone tell me
    if this is accurate?
    Thanks for your help!
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • What is new in Java syntaxes in new Java versions?

    What is new in Java syntaxes in new Java versions?
    What about this sentenses
    1. for (int c:data), where data is array of integer
    2. ArrayList<Object> () ...
    3. Class<?>...
    I can't find this syntaxes in my books and documentation...
    And what Java version is latest?

    dont crosspost
    Edited by language police

  • After downloading the "new version" of Java 6 times, my plugin-check page states that it has disabled my "outdated version" and asks for me to upgrade. What do?

    Background:
    I have had this problem for several months, now. This problem began when an update came for Java on the Firefox Plugin-check. I promptly installed the new Java update. But the Firefox update wouldn't register that I downloaded it, even after I refreshed the page. So, I got rid of the old Java, and downloaded the new Java again. When the page continued to display the same message it had before, I downloaded it a few more times. Finally, Firefox stopped saying that I was out of date. Then a few weeks later maybe, I check Firefox Plugin, and on the page it says that I am outdated in Java. So I downloaded Java again. But Java was still in the list, with red and said that it needed to be updated. I restarted the computer. Then, I restarted Mozilla Firefox with no add-ons. When Java still appeared that it needed to be updated, I gave up and didn't do a thing more about it.
    Problem:
    Today I decided to check my plugins. Java was not in update the list, and at the top a banner stated, "Missing JAVA? For your safety, Firefox has disabled your outdated version of Java. Please upgrade to the latest version." I clicked "upgrade to the latest version" and was led to the Java page. I clicked the download button. My cache stated that this was the (6) download of that same Java plugin (see background). I chose to re-download it anyways. But Firefox still insists that I have not downloaded it.
    Question:
    Do I need to go to the control panel of Java and change something? Do I need to fix some setting on Firefox? Should I disable Java altogether, delete all Java-related files on my computer, and start all over with Java? What should I do?

    Try using http://ninite.com/java/ninite.exe to install Java. Please note that even though you download it you have to double click it to get it to run and install.

  • Looking for Java programmers for a new project

    I am currently looking to find about 5 people to start a new company to develop some ebusiness related business ideas. Location does not matter, only creativity and a willingness to change the status quo. If you are interested email me at [email protected] I am just a guy with some really unique ideas looking for people that share my vision and that are looking to start a company from the ground up.

    Hi,
    Are you still looking for Java programmers? Can we participate in your work offline? I am in France now. Tell me what exactly you need? I am 5yers experienced in Java technlogy.
    Reply back to [email protected]
    Regards,
    Murthy

  • Repeat of last request for new OC4J with Java SSO

    Problem: When a request is redirected to the 2nd OC4J in a group, reauthentication with Java SSO occurs as expected. However, the request has to be repeated with the 2nd OC4J before it is actually executed. How can I fix this?
    Scenario:
    Java SSO is set up for 2 OC4J instances (home1 and home2) in the same server and group.
    The same ADF application is deployed to both OC4J instances.
    1st request goes to home1. User logs in on java_sso login page.
    Home1 dies.
    User clicks on link to navigate to a different page. 2nd request is submitted.
    Log messages for home2 show the reauthentication.
    Navigation to the different page doesn't happen.
    User clicks the link again.
    This time, navigation occurs as expected.

    I don't think starting a new OC4J for failover will resolve this problem since the requests are being routed to the other OC4J in the group when the first one "fails". It's just the matter of having to resubmit the last request made when the first OC4J fails.
    Since I made the original post, I added application clustering to see if that would resolve this. It doesn't. I did verify that I have the same session id with the 2nd OC4J. Any other ideas would be appreciated!

  • Upgraded both computers in the household and found Lion is too disruptive to workflow.  Do I turn in the new laptop for a pre-Lion rebuild to keep Snow Leopard, or do I return computer and get upgraded memory to improve performance of existing MacBookPro?

    Upgraded both computers in the household and found Lion is too disruptive to workflow. 
    Do I turn in the new laptop for a pre-Lion rebuild to keep Snow Leopard, or do I return new computer and get upgraded memory to improve performance of existing MacBookPro?  I'm mostly still happy with existing MacBookPro, but Aperture doesn't work, the computer can't handle it.
    Other possibility is setting up virtual machine with Snow Leopard server software on new computer.
    Any opinions on what would allow moving forward with the least hassle and best workflow continuity?

    hi,
    what year and specs does the MBP have

  • Is new Windows Mobile VM for Java ME in new SDK 3.0 for common users?

    Hi,
    There are bunch of buggy VMs for WM Platform such as Esmertec JBED, Esmertec JBLEND, IBM J9 etc. They have lot of bugs and they don't support neccessary JSRs. Now I have read about Windows Mobile integration in new SDK 3.0 EA for Java ME - I undestand that there is a new VM for WM from Sun, is that right? But when I installed CAB version, it seams it is just for on-device debugging with connected Wireless Toolkit on PC. I can't launch midlets located in my WM device on it. Is there also VM for common users? So they could install virtual machine and then install their midlets? I think many developers and users would apreciate it. Or is it at least in plan to release such VM?

    Jackson_Bill wrote:
    What IDE are you using and what platform?Read first.
    Moh Bob wrote:
    I'm using J2ME platform SDK 3.0
    db

Maybe you are looking for