"வணக்கம், அமிகோ! நேற்று நாங்கள் மல்டித்ரெடிங்கின் நன்மைகள் மற்றும் வசதிகளைப் பற்றி விவாதித்தோம். இப்போது தீமைகளைப் பார்க்க வேண்டிய நேரம் இது. மேலும், துரதிர்ஷ்டவசமாக, அவை சிறியவை அல்ல."

முன்பு, ஒரு நிரலை ஒருவருக்கொருவர் முறைகள் என்று அழைக்கும் பொருள்களின் தொகுப்பாகப் பார்த்தோம். இப்போது எல்லாம் கொஞ்சம் சிக்கலானதாகிறது. நிரல் என்பது பல "சிறிய ரோபோக்கள்" (இழைகள்) அதன் வழியாக ஊர்ந்து செல்லும் மற்றும் முறைகளில் உள்ள கட்டளைகளை செயல்படுத்தும் பொருள்களின் தொகுப்பைப் போன்றது.

இந்தப் புதிய விளக்கம் முதல் விளக்கத்தை ரத்து செய்யாது. அவை இன்னும் பொருள்கள், அவை இன்னும் ஒருவருக்கொருவர் முறைகள் என்று அழைக்கப்படுகின்றன. ஆனால் பல நூல்கள் உள்ளன என்பதை நாம் நினைவில் கொள்ள வேண்டும், மேலும் ஒவ்வொரு நூலும் அதன் சொந்த வேலை அல்லது பணியைச் செய்கிறது.

ஒரு திட்டம் மிகவும் சிக்கலானதாகி வருகிறது. வெவ்வேறு நூல்கள் வெவ்வேறு பொருள்களின் நிலையை அவை செய்யும் பணிகளின் அடிப்படையில் மாற்றுகின்றன. மேலும் அவர்கள் ஒருவரையொருவர் காலில் மிதிக்க முடியும்.

ஆனால் ஜாவா இயந்திரத்தின் உள்ளே மிக மோசமான விஷயங்கள் நடக்கின்றன. நான் ஏற்கனவே கூறியது போல், செயலி தொடர்ந்து ஒரு நூலில் இருந்து மற்றொன்றுக்கு மாறுவதன் மூலம் நூல்களின் வெளிப்படையான ஒரே நேரத்தில் அடையப்படுகிறது. இது ஒரு நூலுக்கு மாறுகிறது, 10 மில்லி விநாடிகளுக்கு வேலை செய்கிறது, அடுத்த திரிக்கு மாறுகிறது, 10 மில்லி விநாடிகளுக்கு வேலை செய்கிறது மற்றும் பல. இங்கே சிக்கல் உள்ளது: இந்த சுவிட்சுகள் மிகவும் பொருத்தமற்ற தருணங்களில் ஏற்படலாம். இந்த உதாரணத்தைக் கவனியுங்கள்:

முதல் நூலின் குறியீடு இரண்டாவது நூலின் குறியீடு
System.out.print ("Nick is");
System.out.print ("");
System.out.print ("15");
System.out.print ("");
System.out.print ("years old");
System.out.println ();
System.out.print ("Lena is");
System.out.print ("");
System.out.print ("21");
System.out.print ("");
System.out.print ("years old");
System.out.println ();
நாங்கள் எதிர்பார்த்தது காட்டப்படும்
நிக்கிற்கு 15 வயது
லீனாவுக்கு 21 வயது
உண்மையான குறியீடு செயல்படுத்தல் முதல் நூலின் குறியீடு இரண்டாவது நூலின் குறியீடு
System.out.print ("Nick is");
System.out.print ("Lena is");
System.out.print (" ");
System.out.print (" ");
System.out.print ("15");
System.out.print ("21");
System.out.print (" ");
System.out.print (" ");
System.out.print ("years old");
System.out.println ();
System.out.print ("years old");
System.out.println ();
System.out.print ("Nick is");
//other thread is running
//other thread is running
System.out.print (" ");
System.out.print ("15");
//other thread is running
//other thread is running
System.out.print (" ");
System.out.print ("years old");
System.out.println ();
//other thread is running
//other thread is running
//other thread is running
System.out.print ("Lena is");
System.out.print (" ");
//other thread is running
//other thread is running
System.out.print ("21");
System.out.print (" ");
//other thread is running
//other thread is running
//other thread is running
System.out.print ("years old");
System.out.println ();
உண்மையில் என்ன காட்டப்படுகிறது
நிக்  லீனாவுக்கு   15  21  வயது
_

மேலும் இங்கே மற்றொரு உதாரணம்:

குறியீடு விளக்கம்
class MyClass
{
private String name1 = "Ally";
private String name2 = "Lena";
public void swap()
{
String s = name1;
name1 = name2;
name2 = s;
}
}
இடமாற்று முறை மற்றும் மாறிகளின் swapமதிப்புகள் .name1name2

ஒரே நேரத்தில் இரண்டு இழைகளில் இருந்து அழைக்கப்பட்டால் என்ன நடக்கும்?

உண்மையான குறியீடு செயல்படுத்தல் முதல் நூலின் குறியீடு இரண்டாவது நூலின் குறியீடு
String s1 = name1; //Ally
name1 = name2; //Lena
String s2 = name1; //Lena(!)
name1 = name2; //Lena
name2 = s1; //Ally
name2 = s2; //Lena
String s1 = name1;
name1 = name2;
//other thread is running
//other thread is running
name2 = s1;
//other thread is running
//other thread is running
//other thread is running
String s2 = name1;
name1 = name2;
//other thread is running
name2 = s2;
அடிக்கோடு
இரண்டு மாறிகளும் "லீனா" மதிப்பைக் கொண்டுள்ளன.
"அல்லி" பொருள் அதை உருவாக்கவில்லை. அது தொலைந்து விட்டது.

"இவ்வளவு எளிமையான அசைன்மென்ட் ஆபரேஷன் மூலம் இதுபோன்ற பிழைகள் சாத்தியம் என்று யார் யூகித்திருப்பார்கள்?!"

"ஆம், இந்தப் பிரச்சனைக்கு ஒரு தீர்வு இருக்கிறது. ஆனால் இதைப் பற்றி சிறிது நேரம் கழித்துப் பேசுவோம் - என் தொண்டை வறண்டு விட்டது."