473,466 Members | 3,167 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

java synchronization

dmjpro
2,476 Top Contributor
Expand|Select|Wrap|Line Numbers
  1. synchronized void method(){
  2.  this.x = 100;
  3.  this.y = 200;
  4. }
  5.  
the method is synchronized, means only one thread runs the method fully and returns...now my question when a method is synchronized then instance members(data/method) used inside it, are synchronized or not?
Jun 3 '10 #1
3 2466
jkmyoung
2,057 Recognized Expert Top Contributor
Not necessarily. Another thread could be running another method which also changes those values. You have not locked on the object itself or its members, just the method.
Jun 3 '10 #2
dmjpro
2,476 Top Contributor
that's what i wanted to know ;)
Jun 3 '10 #3
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
When a thread is executing a synchronized block other threads can not access any methods or members of that class if it is object level lock. Else they can execute.

Regards
Dheeraj Joshi
Jun 3 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Meh-Lit Kim | last post by:
Hi all, I know that under Unix/Linux, there is a max number synchronization objects (semaphores etc.) that one can create. I assume that likewise, there is a max number of mutexes and...
5
by: Egghead | last post by:
Hi, Does anyone know if there is any C#'s class equivalent to java.utl.Vector? I think the System.Collections.ArrayList is not the same: In java: for(int i = 0; i<myVector.length;i++) {...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
6
by: Chris Ashurst | last post by:
Hi, I'm coming in from a despised Java background, and I'm having some trouble wrapping my head around sharing an object between multiple instances of a single class (in simpler terms, I would say...
4
by: hostel | last post by:
import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Administrator */ public class sync { public static void main(String args)
350
by: Lloyd Bonafide | last post by:
I followed a link to James Kanze's web site in another thread and was surprised to read this comment by a link to a GC: "I can't imagine writing C++ without it" How many of you c.l.c++'ers use...
318
by: King Raz | last post by:
The shootout site has benchmarks comparing different languages. It includes C# Mono vs Java but not C# .NET vs Java. So I went through all the benchmark on the site ... ...
6
by: Dmitriy V'jukov | last post by:
On 2 Á×Ç, 20:47, "Dmitriy V'jukov" <dvyu...@gmail.comwrote: Q: Can I use Relacy Race Detector to check my algo againts other that C ++0x memory models (x86, PPC, Java, CLI)? A Yes, you...
13
by: eternalLearner | last post by:
i am writing an client application that connects to the server and then sends data to server. but, the problem is that i get a java.net.ConnectException: Connection refused error. The code i have...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.