Skip to main content
Version 3
Source Link
rolfl
  • 98.1k
  • 4
  • 117
  • 238

This is not an answer, but a talking point about whether this is on, or off topic


Version 1: (off-topic - asking for code to be written)

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


Version 2: (on the fence, but probably on-topic)

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


Version 3: (on-topic)

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

Have I successfully implemented the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

This is not an answer, but a talking point about whether this is on, or off topic


Version 1: (off-topic - asking for code to be written)

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


Version 2:

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

This is not an answer, but a talking point about whether this is on, or off topic


Version 1: (off-topic - asking for code to be written)

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


Version 2: (on the fence, but probably on-topic)

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


Version 3: (on-topic)

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

Have I successfully implemented the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

Add off-topic reason
Source Link
rolfl
  • 98.1k
  • 4
  • 117
  • 238

This is not an answer, but a talking point about whether this is on, or off topic


Version 1: (off-topic - asking for code to be written)

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


Version 2:

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

This is not an answer, but a talking point about whether this is on, or off topic


Version 1:

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


Version 2:

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

This is not an answer, but a talking point about whether this is on, or off topic


Version 1: (off-topic - asking for code to be written)

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


Version 2:

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

Better formatting.
Source Link
syb0rg
  • 21.9k
  • 17
  • 24

This is not an answer, but a talking point about whether this is on, or off topic


---- VersionVersion 1 ----:


What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


---- VersionVersion 2 ----:


What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

This is not an answer, but a talking point about whether this is on, or off topic


---- Version 1 ----


What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


---- Version 2 ----


What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

This is not an answer, but a talking point about whether this is on, or off topic


Version 1:

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}


Version 2:

What is the best practice regarding synchronization?

I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.

What are the best practices for making my code thread-safe?

public class Foo {

    private String foo = "Foo";

    public synchronized void setFoo(String newfoo) {
        this.foo = newfoo;
    }

    public String getFoo() {
        return foo;
    }
}

Added version 2.
Source Link
rolfl
  • 98.1k
  • 4
  • 117
  • 238
Loading
Post Made Community Wiki
Source Link
rolfl
  • 98.1k
  • 4
  • 117
  • 238
Loading